I have a XAML file representing the main window of a WPF application.
Now I want this window to display content that is specified by another XAML file.
This works, but the DataContext
is lost in the C# code of my UserControl
.
I think the <Frame Source=....>
is breaking the logical tree of WPF in some way.
I'd like to have the same behavior as if <Frame Source=....>
was simply substituted by the Content1.xaml file content, i.e. that the DataContext
of the surrounding Window
class is inherited to the UserControl
.
Is there a simple way to overcome this issue? All solutions that I found seem like overkill.
Pseudocode
MainWindow.xaml
<Window ....>
<Frame Source="Content1.xaml" />
</Window>
Content1.xaml
<UserControl ....>
<!-- Content goes here -->
</UserControl>