C # WPF Exchange data between page in frame and MainWindow

In my MainWindow.xaml, I have the following code:

<Frame Name="FrmView" Source="Overview.xaml" NavigationUIVisibility="Hidden" />

In Overview.xaml.cs, now I want to get an ObservableCollection, which is declared and initialized in MainWindow.xaml.cs. Is there a way to access MainWindow from a frame / page?

+3
source share
2 answers

you can try Window.GetWindow (this) on the page. This should give you a top-level window.

+1
source

You need to declare your application as follows:

  • or a resource present in the dictionary application resource, so other windows can access it

  • or as a variable with code and get / set it using code, not from XAML.

0
source

All Articles