我有查看源代码
<view:ValidationBaseView x:Class="test.View.test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:res="clr-namespace:test.Resources"
xmlns:local="clr-namespace:test"
xmlns:view="clr-namespace:test.View"
xmlns:viewModel="clr-namespace:test.ViewModel"
Height="Auto" Width="Auto">
<UserControl.DataContext>
<viewModel:testviewmodelx:Name="testview"/>
</UserControl.DataContext>然后我有了我的UI元素,我已经将组合框与ObservableCollection绑定在一起。但我知道我需要在组合中有排序的值。
<ComboBox Grid.Column="0"
Grid.Row="3"
x:Name="combo1"
Margin ="0"
ItemsSource="{Binding Path=test}"
DisplayMemberPath="testpath"/>发布于 2012-04-18 00:11:17
使用ICollectionView。如下所示:
// this is your existing collection of items
var items = ...;
var cv = new ListCollectionView(items);
// this will sort by the Foo property of each item
cv.SortDescriptions.Add(new SortDescription("Foo"));在您的视图中,绑定到集合视图,而不是原始项。
https://stackoverflow.com/questions/10194850
复制相似问题