WPF如何在水平堆栈面板中的每个项目下方放置分隔符
WPF how to put separator below each item in horizontal stackpanel
我有一个水平堆栈面板,我可以在上面添加项目。我想在每个项目名称下方添加一个分隔符,而不是在名称的右侧,并且该分隔符应该跨越整个页面。到目前为止,这两个问题对我没有帮助: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>
使第一个堆栈面板垂直并将内容控件和标签放在水平堆栈面板内。像这样:
<StackPanel>
<StackPanel Orientation="Horizontal">
<ContentControl Content="{StaticResource Appbar_Suitcase}" />
<Label Content="{Binding Name}"/>
</StackPanel>
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
</StackPanel>
我有一个水平堆栈面板,我可以在上面添加项目。我想在每个项目名称下方添加一个分隔符,而不是在名称的右侧,并且该分隔符应该跨越整个页面。到目前为止,这两个问题对我没有帮助: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>
使第一个堆栈面板垂直并将内容控件和标签放在水平堆栈面板内。像这样:
<StackPanel>
<StackPanel Orientation="Horizontal">
<ContentControl Content="{StaticResource Appbar_Suitcase}" />
<Label Content="{Binding Name}"/>
</StackPanel>
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
</StackPanel>