Xaml页面可以成为WPF中Canvas的子项吗? [英] Can a Xaml page be a child of Canvas in WPF?

查看:103
本文介绍了Xaml页面可以成为WPF中Canvas的子项吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请说明 Canvas控件 是否可以保存Xaml页面内容(我们可以通过阅读 Xaml页面动态地将Xaml加载到Canvas中吗? )



谢谢。

Please clarify whether the Canvas control can hold a Xaml page content (can we load Xaml into Canvas dynamically by reading the Xaml page?)

Thanks.

推荐答案

虽然我从未试图在画布控件中直接托管页面,我可以确认你可以在坐在画布控件上的Frame控件中托管它。然后设置Frame控件的源以显示Page控件。请参阅以下内容:

Whilst I have never tried to directly host a page in the canvas control, I can confirm that you can host it in a Frame control sitting on the canvas control. Then set the source of the Frame control to show the Page control. Please see below:
<canvas>
    <frame x:name="m_ChildPageView" xmlns:x="#unknown">
        Source="ChildPageView.xaml" 
        Canvas.Left="150" Canvas.Top="150"
        Width="2800" Height="1500"/>
</frame></canvas>





此解决方案允许您显示内容,而无需自己阅读XAML页面。



This solution would allow you to show your content, without having to read the XAML page yourself.


这篇关于Xaml页面可以成为WPF中Canvas的子项吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆