如何在WPF中获取列表框选定的索引 [英] how to get List box selected index in wpf

查看:219
本文介绍了如何在WPF中获取列表框选定的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当将不同的xaml页作为数据容器绑定时,如何在wpf中获取列表框选择的索引.

how to get List box selected index in wpf when it is binding different xaml page as data container. selected index, item,value, items.currentItem is not working.

推荐答案

首先,您需要在视图模型中实现INotifyPropertyChanged 接口并提高<Rule 属性设置器中的c1>事件.否则,绑定到SelectedRule 属性的控件将不会在更改后知道"
First off, you need to implement INotifyPropertyChanged interface in your view model and raise the PropertyChanged event in the setter of the Rule property. Otherwise no control that binds to the SelectedRule property will "know" when it has been changed


这篇关于如何在WPF中获取列表框选定的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆