Reputation: 1225
In a <ControlTemplate>
for a Control
that inherits from ItemsControl
, I have defined the following:
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style>
<Setter Property="FrameworkElement.MinHeight" Value="16" />
<Setter Property="FrameworkElement.Margin" Value="7,0,0,0" />
<Setter Property="Button.MinWidth" Value="75" />
<Setter Property="Button.MaxWidth" Value="120" />
<Setter Property="Button.Height" Value="23" />
</Style>
</Setter.Value>
</Setter>
I keep wondering whether this is a good practice. Note that the control in question should only accept objects that descend from FrameworkElement
. Note also that I want to avoid having to write a ItemContainerStyleSelector
and would like to do that in XAML.
Upvotes: 0
Views: 106
Reputation: 1825
I find it to be better practice to set the TargetType on the Style tag itself than qualifying each property with their actual type. Is your generic list adding multiple types of elements? If so you need to consider that all of these setters may not mesh well with different types of elements.
Upvotes: 1