更新时间:2023-12-02 18:20:28
没有理由使用
。 ContentControl
中的页面页面
是 UserControl
类的子类,它增加了对在 Frame中使用的支持。
控件以支持导航,后退堆栈/历史记录等。您可能应该将 Page
替换为 UserControl
在XAML中以及后面的代码,因此您最终会得到这样的东西:
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>
您可以将 UserControl
本身放在 DataTemplate
如果要在 ContentControl $ c $中用作
DataTemplate
c>:
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>