Hi
Where do you locate your convertors? do you put them in the Window.Resources section? or in the UserControl they are being used for? Neither of these options is good. You should put it in the App.Xaml file and here is why:
Lets look at the following example:
Here is our Window:
1: <Window x:Class="ConvertorLocation.Window1"
2: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4: xmlns:my="clr-namespace:ConvertorLocation"
5: Title="Window1" Height="300" Width="300">
6: <Grid>
7: <ItemsControl ItemsSource="{Binding}">
8: <ItemsControl.ItemTemplate>
9: <DataTemplate>
10: <my:UserControl1></my:UserControl1>
11: </DataTemplate>
12: </ItemsControl.ItemTemplate>
13: </ItemsControl>
14: </Grid>
15: </Window>
Lately I took part in several code reviews and I noticed that whenever people need to extract the month name from the datetime object many different solutions are presented. Some of the solutions were not very successful, so I decided to shed some light on this issue through an example.
These are the most common (and [...]
We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution
Learn More