可以采用替代的解决方案

            <ListBox x:Name="selectBookListBox" SelectionChanged="selectBookListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<!--书名-->
<TextBlock Text="{Binding Path=BookName}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
        private void selectBookListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MessageBox.Show((e.AddedItems[0] as BookEntity).BookId.ToString());
}

 

把需要的绑定到Tag的内容,加入到绑定的实体类中就行。


相关文章:

  • 2021-09-17
  • 2022-12-23
  • 2021-11-18
  • 2021-06-17
  • 2021-05-26
  • 2021-08-06
  • 2021-07-15
  • 2022-12-23
猜你喜欢
  • 2022-02-22
  • 2021-06-19
  • 2021-09-17
  • 2022-12-23
  • 2021-12-26
  • 2021-09-02
  • 2022-12-23
相关资源
相似解决方案