在IDE(Visual Studio 2017)设计时Wpf Show Frame的内容(Wpf页面) [英] Wpf Show Frame's Content(Wpf Page) at Design Time In IDE(Visual Studio 2017)

查看:132
本文介绍了在IDE(Visual Studio 2017)设计时Wpf Show Frame的内容(Wpf页面)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个框架控件,它的源设置为xaml中的页面,如下所示:

I have a frame control and it's source set to a page in xaml like this:

Source="/Myapp;component/MyFolder/Mypage.xaml"

当我运行应用程序时,框架控件会显示该页面.但是我想看到页面在设计时在框架控制下显示.(Visual Studio 2017).它仅显示如下文本:(/Myapp;component/MyFolder/Mypage.xaml)

Frame control shows the page when i run the application. But i want to see page displaying at frame control at design time.(Visual Studio 2017). It only shows a text like this: (/Myapp;component/MyFolder/Mypage.xaml)

推荐答案

这将在设计时适用于单个页面.

This will work for a single page in design time.

确保在根xaml元素中定义了Blend命名空间.

Make sure you have the Blend namespace defined in your root xaml element.

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

然后将d:DesignInstace属性添加到您的Frame.

Then add the d:DesignInstace attribute to your Frame.

<Frame d:DataContext="{d:DesignInstance Type=local:MyPage, IsDesignTimeCreatable=True}"  
       Content="{Binding}"/>

然后在InitializeComponent调用之后,将类似这样的内容添加到托管Frame的构造函数中.

Then add something like this to your to the constructor where your Frame is hosted, after the InitializeComponent call.

public MainWindow()
{
    InitializeComponent();
    _frame.Content = null;
    _frame.NavigationUIVisibility = NavigationUIVisibility.Visible;
    _frame.Source = new Uri("/Wpf;component/MyPage.xaml", UriKind.Relative);
}

这应该可以让您正常使用Source属性进行导航.

That should allow you to navigate with the Source property normally.

这篇关于在IDE(Visual Studio 2017)设计时Wpf Show Frame的内容(Wpf页面)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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