We have all used WPF DataTemplates, but I bet most of you never gave thought to the meaning of the x:Key attribute. We all know the meaning of the DataType attribute, which determines to what type of data the template will apply to. But what about the x:Key why is it there? Lets tale a look at the following code:
<Window.Resources> <DataTemplate DataType="{x:Type data:s}"> <Button Width="50" Height="50"> <TextBlock Text="{Binding text}"></TextBlock> </Button> </DataTemplate> </Window.Resources> <Canvas> <ItemsControl ItemsSource="{Binding}"> </ItemsControl> </Canvas>
Often we want to display a list of elements and allow the user to sort them in various ways. There are many ways to do it and I wanted to show you how to use a SortDescription Object. What is a SortDescription object you ask? It receives two parameters in its constructor: the first is [...]