I am trying to port an application from silverlight to wpf. Unfortunatley I am new to both. Is there an equvivalent to the following Silverlight code in WPF?
private static Canvas GetCanvas()
{
var uc = Application.Current.RootVisual as UserControl;
if (uc == null)
{
return null;
}
return uc.FindName("ChoiceCanvas") as Canvas;
}
Currently I am using
Application.Current.MainWindow.FindName("ChoiceCanvas") as Canvas;
But this doesn't work, perhaps because ChoiceCanvas is something located in a UserControl and not in the MainWindow?