我有一个ListBox
从项目源创建项目的项目,我需要每个项目都有一个边框,但是我不知道在哪儿设置ListBox
项目样式。
<ListBox x:Name="m_list">
<ListBox.ItemTemplate>
<DataTemplate>
<Expander IsExpanded="True">
<CustomUserControl />
</Expander>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsSource>
<Binding Path="DataToBeEditied" />
</ListBox.ItemsSource>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
自定义用户控件是我创建的用户控件,用于编辑DataToBeEdited中ObservableCollection
的数据
根据我的发现,应该有办法,但没有任何解释。我该怎么做?
您可以定义一个ItemContainerStyle
:
<ListBox>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="BorderThickness" Value="2" />
<Setter Property="BorderBrush" Value="Red" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1199 次 |
最近记录: |