具有嵌套类型的XAML DataContext DesignInstance [英] XAML DataContext DesignInstance with nested types

查看:66
本文介绍了具有嵌套类型的XAML DataContext DesignInstance的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在XAML中为d:DesignInstance指定嵌套类型?如果可以,怎么办?

Is it possible to specify a nested type for d:DesignInstance in XAML? And if so, how?

如果我具有以下类结构:

If I have the following class structure:

namespace MyApp
{
    public class OuterClass
    {
        public class InnerClass
        {
             public string SomeData {get;set;}
        }
    }
}

如何将 InnerClass 类型用作DesignInstance?以下内容不起作用:

How can I use the InnerClass type as a DesignInstance? The following doesn't work:

<phone:PhoneApplicationPage
    ...
    xmlns:local="clr-namespace:MyApp" 
    ...
    d:DataContext="{d:DesignInstance Type=local:OuterClass.InnerClass}"
 >

推荐答案

尝试将.更改为 + .像这样:

Try changing . to +. Something like:

<phone:PhoneApplicationPage
    ...
    xmlns:local="clr-namespace:MyApp" 
    ...
    d:DataContext="{d:DesignInstance Type=local:OuterClass+InnerClass}">

这篇关于具有嵌套类型的XAML DataContext DesignInstance的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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