[英]WPF - can't display page content
I'm trying to display a wpf page inside a wpf window (to reproduce some bug in an isolated environment) and I'm unable to see the page inside the window. 我正在尝试在wpf窗口中显示wpf页面(以在隔离的环境中重现一些错误),但无法在窗口中看到该页面。
My code is quite simple: 我的代码很简单:
MainWindow.xaml: MainWindow.xaml:
<ContentPresenter
Content="{Binding ElementName=Root, Path=MyPage}"
ContentTemplate="{Binding ElementName=Root, Path=MyPage.TT}"
/>
MainWindow.xaml.cs: MainWindow.xaml.cs:
public MainWindow()
{
InitializeComponent();
this.MyPage = new Page1();
}
Page1.xaml: Page1.xaml:
<DataTemplate x:Name="TT">
<Grid>
<TextBlock Text="doodle dood doodle da"></TextBlock>
</Grid>
</DataTemplate>
Any Idea why MainWindow appears empty? 知道MainWindow为什么显示为空吗?
Thanks, Li 谢谢李
Path=MyPage.TT
寻找一个称为TT
的属性, TT
很可能不是属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.