Tomasz
Tomasz

Reputation: 2071

ItemTemplate DesignTime hints for custom control

I would like to create custom control with ItemsSource, which ItemTemplate for these items.

I have made it working, but one thing is left:

I would like to have DesignTime helper for binding within DataTemplate. Right now I can bind properties from Collection object, but there's no hints in XAML like with other bindings.

Of course I can do something like this:

<DataTemplate>
    <StackPanel d:DataContext="{d:DesignInstance models:User}">
        <Label Content="{Binding FirstName}" />
        <Label Content="{Binding LastName}" />
    </StackPanel>
</DataTemplate>

But I would like to avoid DesignTime instances entered manually.

Is there a way to do this?

Upvotes: 0

Views: 153

Answers (1)

Toby Crawford
Toby Crawford

Reputation: 827

<DataTemplate DataType={x:Type User}>

By telling the DataTemplate the type that it represents; intellisense will give you DesignTime hints as to the properties available for Binding expressions

Upvotes: 2

Related Questions