I am binding a collection of images that I retrieve from IsolatedStorage to my View, but I am having issues with changing the order in which images are displayed. There is a timestamp associated with each image, and I would like to be able to sort by either ascending or descending order. As of now the binding works, but when I attempt to change the sort order before binding to my listbox, nothing shows on the UI.
MainPage.xaml
<ListBox x:Name="Recent" ItemsSource="{Binding Pictures}" Margin="8"
SelectionChanged="recent_SelectionChanged" toolkit:TiltEffect.IsTiltEnabled="True"
ItemContainerStyle="{StaticResource MyStyle}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
MainPage.xaml.cs
// Constructor
public MainPage()
{
InitializeComponent();
//This is working, but is not sorted
//DataContext = PictureRepository.Instance;
//Attempt at sorting before binding
//from SettingsPage, if AscendingSort = True then sort ascending
if (Settings.AscendingSort.Value)
{
//Give no errors, but does not display on UI
DataContext = PictureRepository.Instance.Pictures.OrderBy(s => s.DateTaken);
}
else
{
DataContext = PictureRepository.Instance.Pictures.OrderByDescending(s => s.DateTaken);
}
}
Not sure exactly what the issue is here? Note, when debugging, I can see that PictureRepository.Instance contains the images in which to display in the view.