I want to write XAML template of a combobox to increase the spaces/padding between items. I searched for this but almost end up with the ItemsPresenter:
<ItemsPresenter x:Name="ItemsPresenter"
                KeyboardNavigation.DirectionalNavigation="Contained"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
How can I format the 开发者_如何学Pythonitem (border, padding, font...) using this template? Please help.
You can use ItemContainerStyle to apply a style to the ComboBoxItems that sets properties such as padding:
<ComboBox ItemsSource="{Binding}">
    <ComboBox.ItemContainerStyle>
        <Style TargetType="ComboBoxItem">
            <Setter Property="Padding" Value="5"/>
            <Setter Property="BorderBrush" Value="Blue"/>
            <Setter Property="BorderThickness" Value="2"/>
            <Setter Property="FontFamily" Value="Courier New"/>
        </Style>
    </ComboBox.ItemContainerStyle>
</ComboBox>
If you want it to apply to all combo boxes, you could instead create an implicit style for ComboBoxItem in your Resources:
<Window.Resources>
    <Style TargetType="ComboBoxItem">
        <Setter Property="Padding" Value="5"/>
    </Style>
</Window.Resources>
<StackPanel>
    <ComboBox ItemsSource="{Binding}"/>
    <ComboBox ItemsSource="{Binding}"/>
</StackPanel>
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论