I have a ContentControl where I want to load the page myPage2. My XAML Codefrom this page looks like this:
There is no reason to use a Page
within a ContentControl
. A Page
is a subclass of the UserControl
class that adds support for being used within a Frame
control to support navigation, back stack/history, etc. You should probably replace Page
with UserControl
in XAML and code behind, so you would end up with something like this:
<UserControl x:Class="ExampleApp.myControl2">
<Grid x:Name="Content" Height="651" Width="941" Background="White">
...
...
</Grid>
</UserControl>
You can put the UserControl
itself in a DataTemplate
if you want to use it as a DataTemplate
in a ContentControl
:
<ContentControl
xmlns:controls="using:ExampleApp">
<ContentControl.Resources>
<DataTemplate
x:Key="Test">
<controls:myControl2 />
</DataTemplate>
</ContentControl.Resources>
</ContentControl>