UserControl with Design Time Data, but data not rendered when control used

1k views Asked by At

Hi I have a simple user control with some Blend generated design time data:

<UserControl x:Class="CustomerProfile.View.CustomerProfile"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:vm="clr-namespace:CustomerProfile.ViewModel"
         mc:Ignorable="d" 
         d:DesignHeight="400" d:DesignWidth="400">

<Grid Margin="8" d:DataContext="{d:DesignData /SampleData/CustomerProfileViewModelSampleData.xaml}">
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="25" />
        <RowDefinition />
    </Grid.RowDefinitions>

    <Label Content="Surname" />
    <TextBox Grid.Column="1" Text="{Binding Account.Surname}" />

</Grid>

This is all good, and when I open the user control in Blend or Cider I see the generated data.

However, I am using the UserControl in a Window, like this:

<Window x:Class="Demo.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cp="clr-namespace:CustomerProfile.View;assembly=CustomerProfile"
    Title="Demo" Height="350" Width="525">
<Grid>
    <cp:CustomerProfile />
</Grid>

When I open this Window in Blend or Cider I do NOT see the design time data in the User Control.

Is there any way around this? Am I going about things the wrong way?

Thanks in advance...

0

There are 0 answers