问题
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