WPF: nested designData

I have the following simplified element on the page:

<Grid x:Name="LayoutRoot"
      DataContext="{Binding Source={StaticResource MyContext}}"
      d:DataContext="{d:DesignData SampleData/MyContextSampleData.xaml}">

The MyContext class has some properties that are links, not just plain data. One such property for this class is public MyReferenceType MyReferenceProperty.

I created data samples for MyContext and MyReferenceType.

Here is MyReferenceTypeSampleData.xaml:

<data:MyReferenceType
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:data="clr-namespace:MyNamespace.Data;assembly=MyNamespace.Data"
 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

 MyValueProperty0="True"
 MyValueProperty1="123"
 MyValueProperty2="abc"
/>

and MyContextSampleData.xaml is where I am at a dead end.

<data:MyContext
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:data="clr-namespace:MyNamespace.Data;assembly=MyNamespace.Data"
 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

 MyReferenceProperty="{d:DesignData SampleData/MyReferenceTypeSampleData.xaml}"
/>

MyReferenceProperty="{d:DesignData SampleData/MyReferenceTypeSampleData.xaml}"of course wrong. I am trying to make an equivalent of what this does for installation d:DataContext. I want the property to be set in the data samples in sampledata xaml.

Is it possible, and if not, then what will be the workaround. Of course, this is a typical use case, because a data layout is rarely just value types. Does anyone know how to handle this?

+4

Source: https://habr.com/ru/post/1543919/


All Articles