私のWindows Phoneプロジェクトには、xmlからのリストボックスバインディングデータがあります
<ListBox x:Name="listBox02">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="20" >
<TextBlock Text="{Binding Namee}"/>
<TextBlock Text="{Binding Examinoo}"/>
<TextBlock Text="{Binding Statuss}"/>
<!--<TextBlock Text="{Binding Idd}"/>-->
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
使用して
XDocument loadedCustomData = XDocument.Load("PeopleCustom.xml");
var filteredData =
from c in loadedCustomData.Descendants("Mathima")
where c.Attribute("Id").Value == "1"
select new Iatriki() {
Namee = "Ονομα: " + c.Attribute("Name").Value,
Examinoo = "Εξάμηνο: " + c.Attribute("Examino").Value,
Idd = c.Attribute("Id").Value,
Statuss = c.Attribute("Status").Value,
};
listBox02.ItemsSource = filteredData;
ボタンクリック時に一覧を「Examinoo」でソートしたい
ボタンのイベント ハンドラは次のとおりです。
private void btn_sort_Click(object sender, RoutedEventArgs e)
{
listBox02.Items.SortDescriptions.Add(
new SortDescription("Content", ListSortDirection.Descending));
}
次のエラーが表示されます。
System.Windows.Controls.ItemCollection' には 'SortDescriptions' の定義が含まれておらず、タイプ 'System.Windows.Controls.ItemCollection' の最初の引数を受け入れる拡張メソッド 'SortDescriptions' が見つかりませんでした (using ディレクティブが不足しているか、またはアセンブリ参照?)`