Search code examples
c#windows-store-apps

How to access an element in UserControl from the MainPage?


I have a UserControl that is an ItemTemplate for a FlipView that exists in my MainPage. This UserControl contains a Canvas which name is x:Name="InkCanvas".

And I want to initialise this Canvas and access it from my MainPage.xaml.cs:

private readonly CanvasManager m_CanvasManager;
m_CanvasManager = new CanvasManager(InkCanvas);

Setting it to static couldn't help! How can it be possible?


Solution

  • It turns out that if this UserControl is not my current ItemTemplate: I can't access any of its controls.