XAML DataContext DesignInstance with nested types

你说的曾经没有我的故事 提交于 2020-03-15 06:29:28

问题


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;}
        }
    }
}

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}"
 >

回答1:


Try changing . to +. Something like:

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


来源:https://stackoverflow.com/questions/14975333/xaml-datacontext-designinstance-with-nested-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!