<Window x:Class="MyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:WpfApplication1"
Title="ContactsSelector" Height="300" Width="300">
<Window.Content>
<src:MyPage>
<!--MyPage is a page that I created and exists in the project-->
</src:MyPage>
</Window.Content>
</Window>
我想将窗口的内容设置为页面,就像我将以编程方式进行操作一样:
Dim w As New MyWindow
Dim p As New MyPage
w.Content = p
w.ShowDialog()
或在窗口的Load事件中设置它,总的来说,我希望它在xaml中完成。
最佳答案
使用Frame元素显示页面内容。
<Window> <Frame Source="/Pages/MyPage.xaml"/> </Window>
关于wpf - 通过XAML将Window.Content设置为页面吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1371056/