How do I order my items bound from model to the list box.
I have defined model that is:
public ObservableCollection<NotificationItem> Classes:
I need to order it by id which is assigned to every notification item.
at present I have definition:
<ListBox ItemsSource="{Binding Classes, Source={StaticResource model}}"
ScrollViewer.VerticalScrollBarVisibility="Visible"
DataContext="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
where I have reference of model:
<Model:ClassModel x:Key="model" />
Update:
where initialisation of the model is done by
try
{
this.notifierModel = this.Resources["model"] as ClassModel;
this.classController.Initialize(this.notifierModel);
}
catch
{
// todo: handle exception
}
You can either order your collection directly on your model (data context), or create a custom CollectionViewSource and bind your ListBox to that instead.