数据网格排序XAML [英] Data grid sorting xaml

查看:52
本文介绍了数据网格排序XAML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有两个数据网格.第一个数据网格由不同的位置组成,因此在第一个数据网格中选择一个项目将填充第二个数据网格中的相应位置名称"和年龄"

绑定是这样完成的

In my application i have two data grid. The 1st data grid consists of different Locations, so selection of one Item in the 1st datagrid will populate the respective locations Name and Age in the second datagrid

The binding is done like this

ObservableCollection<Location> LocationObj
{
get;
set;
}



上述LocationObj绑定到第一个数据网格,并且selecteditem绑定到SelectedLocation属性



the above mentioned LocationObj is bound to the 1st datagrid and the selecteditem is bound to the SelectedLocation Property

Location SelectedLocation
{
get;
set;
}




Location类包含名称和年龄3的ObservableCollection.
在第二个数据网格中,ItemsSource设置为SelecetedLocation.Details,其中包含age和Name的ObservableCollection.
每当用户编辑年龄时,我希望SelectedLocation按年龄排序.




The class Location contains an ObservableCollection of name and age 3
In the second datagrid the ItemsSource is set to SelecetedLocation.Details which contains the ObservableCollection of age and Name.
When ever the user edits an Age, I would like the SelectedLocation to be sorted by Age.

How can i achieve this??

推荐答案

如果要对WPF Datagrid上的列进行排序,可以尝试使用此链接.
以编程方式排序WPF Datagrid列 [ ^ ]

顺便说一句,不要将您的问题文本放在代码块中.那仅意味着仅用于代码.谢谢.
If you want to sort a column on the WPF Datagrid, you can try this link.

Sort WPF Datagrid column programmatically[^]

By the way, do not put your question text inside a code block. That is meant only for code alone. Thanks.


这篇关于数据网格排序XAML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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