通过 XAML 将 Window.Content 设置为页面? [英] Set Window.Content to a page by XAML?
本文介绍了通过 XAML 将 Window.Content 设置为页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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>
我想将一个窗口的内容设置为一个页面,就像我以编程方式做的那样:
I want to set the content of a window to a page, just like I would do it programmatically:
Dim w As New MyWindow
Dim p As New MyPage
w.Content = p
w.ShowDialog()
或者在窗口的Load事件中设置,总之我希望它在xaml中完成.
Or set it in the Load event of the window, summarily I want it to be done in xaml.
推荐答案
使用 Frame 元素来显示页面的内容.
Use a Frame element to show the content of the page.
<Window> <Frame Source="/Pages/MyPage.xaml"/> </Window>
这篇关于通过 XAML 将 Window.Content 设置为页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文