Reputation: 187
I want set a specific height for the DropDownButton ItemTemplate, in particular, I've a lot of elements inside the DropDown Button and actually the list displayed is too long as you can see in the image below, the structure is this:
<Controls:DropDownButton Content="Nazioni" Width="120" Margin="0, 0, 20, 0"
ItemsSource="{Binding Countries}"
ItemTemplate="{StaticResource CombinedTemplate}"/>
Is possible set a specific height?
Upvotes: 0
Views: 308
Reputation: 10349
If you want to set the height of the element that is using the supplied ItemTemplate
to display an item (this element is usually referred to as item container), you should use the ItemContainerStyle
property (inherited from ItemsControl
):
<Controls:DropDownButton (...)>
<Controls:DropDownButton.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Height" Value="..." />
</Style>
</Controls.DropDownButton.ItemContainerStyle>
</Controls.DropDownButton>
If you want to limit the height of the drop-down itself the way to go about it is to use the DropDownButton.MenuStyle
property:
<Controls:DropDownButton (...)>
<Controls:DropDownButton.MenuStyle>
<Style TargetType="ContextMenu" BasedOn="{StaticResource {x:Type ContextMenu}}">
<Setter Property="MaxHeight" Value="..." />
</Style>
</Controls.DropDownButton.MenuStyle>
</Controls.DropDownButton>
Upvotes: 1