我有一些ListViewItem
来自一个集合,我创建了一个DataTemplate
,以便每个ListViewItem
都有一个Button
作为子控件:
<Window.Resources>
<DataTemplate x:Key="ItemTemplate_AwesomeTemplate">
<StackPanel Orientation="Vertical" VerticalAlignment="Stretch">
<Button Content="Awesome Button" Click="Awesome_Button_Click" HorizontalContentAlignment="Center" VerticalAlignment="Bottom" FontWeight="Bold" Foreground="Black"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<ListView x:Name="AwesomeListView" HorizontalAlignment="Left" Height="577" VerticalAlignment="Top" Width="934" ScrollViewer.HorizontalScrollBarVisibility="Visible" Foreground="Black" Margin="10,10,0,0">
<ListView.View>
<GridView>
<GridViewColumn Header="AwesomeHeader" Width="250" CellTemplate="{StaticResource ItemTemplate_AwesomeTemplate}"/>
</GridView>
</ListView.View>
</ListView>
当我点击某个Button
时,是否可以更改包含所点击的IsSelected
的{{1}}的{{1}}属性?
答案 0 :(得分:2)
要更改包含所点击的IsSelected
的{{1}}的{{1}} 属性,您应该使用ListViewItem
来查找此类项目:
Button