Reputation: 445
I'm trying to access some controls (ScrollViewer and Grid) from another window. I tried this:
var reportW = Application.Current.Windows.Cast<Window>().SingleOrDefault(window => window is ReportWindow) as ReportWindow;
ScrollViewer myScrollViewer = reportW.testScrollViewer;
Grid myGrid = reportW.Grd;
Problem is that reportW is allways null
. Is something wrong with my approach and is there any other way to access controls from another window?
Upvotes: 0
Views: 865
Reputation: 69959
Try this:
ReportWindow reportW = Application.Current.Windows.OfType<ReportWindow>().
SingleOrDefault();
Upvotes: 2