I have a ListBox in which the items are created from an item source, I need every item to have a border but I have no clue where I even set a style for ListBox items.
<ListBox x:Name="m_list">
<ListBox.ItemTemplate>
<DataTemplate>
<Expander IsExpanded="True">
<CustomUserControl />
</Expander>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsSource>
<Binding Path="DataToBeEditied" />
</ListBox.ItemsSource>
</ListBox>
The custom user controls are a user control I created which edit the data from DataToBeEdited which is an ObservableCollection of data
According to what I can find there should be a way but no explanation on how. How Do I do it?
You could define an ItemContainerStyle:
<ListBox>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="BorderThickness" Value="2" />
<Setter Property="BorderBrush" Value="Red" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With