Starting with the stock Databound application, I have three strings: LineOne, LineTwo and LineThree. Now imagine I had IntThree instead of LineThree.
The data is added to Items like so:
this.Items.Add(new ItemViewModel() { LineOne = "runtime one", LineTwo = "Maecenas praesent accumsan bibendum", IntThree = 5 });
this.Items.Add(new ItemViewModel() { LineOne = "runtime two", LineTwo = "Dictumst eleifend facilisi faucibus", IntThree = 8 });
and so on.
In the MainPage I have
<StackPanel Margin="0,0,0,17" Width="432">
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="{Binding IntTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
The display order of the items in the Listbox that surrounds the StackPanel depends on the order the items were added to ‘Items’. I plan to have an app bar menu that says ‘Sort by LineOne’, ‘Sort by IntThree’, etc. Does anyone know if it’s possible to sort this list and then refresh the UI. How would I go about doing that? I’m aware that ObservableCollections can update the UI on add and remove, but will this work for sort as well. I cannot make an explicit Navigate to the same page.
Thanks for looking.
You can use linq to order your items