WPF如何基于列表视图中的所选项目更改详细信息 [英] WPF how to change the details based on the selected item in list view

查看:73
本文介绍了WPF如何基于列表视图中的所选项目更改详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含某些项目的列表视图,该列表视图绑定到对象列表.当我从列表视图中选择一个项目时,我想从列表视图中出现一些按钮和TextBlock,当我单击列表视图中的另一个项目时,我希望显示其他按钮和TextBlock.我认为这与用户控制有关,因为我知道让所有按钮和TextBlocks相互重叠,仅使它们可见和隐藏将无法很好地解决我的问题.

我该怎么做呢?

谢谢,

i have a listview with some items, the list view is bind to an list of objects. When i select an item from the list view, i want to appear some buttons and TextBlock down from the listview and when i click on another item in listview i want other buttons and TextBlock to be shown. I think it has something to do with user control because i know that having all the buttons and TextBlocks one over another and just make them visible and hidden will not solve my problem nicely.

How can i make this nice?

Thanks,

推荐答案

问题是什么,您要显示多个项吗?创建一个数据绑定控件并向其中添加项目,它们都将出现.
What is the issue, do you want toi show more than one item ? Create a data bound control and add items to it, and they will all appear.


按照Wes Aday的建议,您应该创建一个用户控件uielement.

当用户在列表中选择一个项目时,这将导致一个事件,或者如果绑定到ViewModel,则更新一个选定的项目属性.由此,您可以使用中介器/事件聚合器来控制两个元素的通信,或者,如果您只是在后面使用代码,则只需创建新的usercontrol实例并插入视图中的区域即可.
As Wes Aday suggested, you should create a usercontrol uielement.

When the user selects an item in the list, this will cause an event or if bound to a ViewModel, update a selected item property. From this you could use a mediator / event aggregator to control the two elements communications, or if you are just using code behind then just create a new instance of the usercontrol and insert into an area on the view.


这篇关于WPF如何基于列表视图中的所选项目更改详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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