バインドされたアイテム(ViewModelオブジェクトのリスト)を自動的にソートするための方法はありますか?ItemsControlはアイテムのプロパティの1つに基づいています。 ItemsControlはDataTemplateの一部です。私はCollectionViewSourceがトリックを行うと思ったが、ItemsViewrolにCollectionViewSourceをどのようにバインドするのだろうか? follwoingコードは何もdispaysない:DataTemplateでバインドされたItemsControlをソートする(XAMLのみ)
<--xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"-->
<DataTemplate DataType="{x:Type vm:Company}">
<DataTemplate.Resources>
<CollectionViewSource x:Key="viewSource" Source="{Binding Employees}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="ID" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</DataTemplate.Resources>
<Viewbox>
<ItemsControl ItemsSource="{Binding Source={StaticResource viewSource}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Viewbox>
</DataTemplate>
「雇用」の綴りは間違っていますか?そうでなければ私には大丈夫です。 – Crispy
ViewModelバインディング({x:Type vm:Company})がressourceスコープ内で認識されていないか、評価されていないように見えることはありません。従業員は会社btwの財産です。 – bitbonk