我有一个水平的stackpanel,我在其上添加了项目。我想在每个项目名称下面添加一个分隔符,而不是在名称的右侧,并且该分隔符应该跨越整个页面。到目前为止,这2个问题对我没有帮助:How to add a vertical Separator? How can a separator be added between items in an ItemsControl
查看代码是:
<ListView ItemsSource="{Binding Projects}" Margin="49,188,54,0">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="EventSetter_OnHandler"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<ContentControl Content="{StaticResource Appbar_Suitcase}"/>
<Label Content="{Binding Name}"/>
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
答案 0 :(得分:0)
使第一个stackpanel垂直,并将内容控件和标签放在水平stackpanel中。像这样的东西:
<StackPanel>
<StackPanel Orientation="Horizontal">
<ContentControl Content="{StaticResource Appbar_Suitcase}" />
<Label Content="{Binding Name}"/>
</StackPanel>
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
</StackPanel>