wpf ListBox绑定数据后如何获得ListBoxItem
绑定数据的Listbox如何获取到当前选中的ListBoxItem,如下代码获取到的是VedioScreen的实体。
请教如何获取当前选中的listboxItem项?
XAML:
C#:
请教如何获取当前选中的listboxItem项?
XAML:
<ListBox x:Name="PlayListBox" ItemsSource="{Binding VedioScreenList,Mode=TwoWay}"
SelectedItem="{Binding VedioScreenItem}" SelectionMode="Single"
ItemContainerStyle="{StaticResource ListBoxItemStyle}"
SelectionChanged="PlayListBox_SelectionChanged" />C#:
void PlayListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
VedioScreen vs = PlayWndListBox.SelectedItem as VedioScreen;
var lstitem = (sender as ListBox).SelectedItem as ListBoxItem; //这里lstitem是null
}
...全文
相关推荐
WPF控件样式和模板手册
WPF控件样式模板查询手册
WPF listBox 漂亮的listBOX
WPF listBox 漂亮的listBOX
WPF MultiSelect模式下 拖拽ListBoxItem
WPF 的ListBox控件不支持很多常见的操作。如类似Explorer通过鼠标框选ListBoxItem,并拖拽。Demo实现了这一常见功能。 编译环境:VS2010
WPF之ListBox用法之一源代码
WPF之ListBox用法之一 介绍ItemTemplate用法以及在ItemTemplate模板中使用ListBoxItem属性的方法。
WPF 带有checkbox的ListBox控件
WPF 带有checkbox的ListBox控件,支持绑定!


