gpt4 book ai didi

wpf - 通过XAML将Window.Content设置为页面吗?

转载 作者:行者123 更新时间:2023-12-04 13:30:03 25 4
gpt4 key购买 nike

<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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com