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>

Continue Reading...

Hi all

As you all remember in my article about Custom WPF Context Menu I mentioned that my WPF Binding Converter was a singleton, and I promised to tell you why, so here comes the 3 ways I know of using WPF Binding Converters. We will start from the worst (in my opinion) and move on the the best.

To start off here is the Binding Converter:

Continue Reading...

Did you ever need to convert List(T1) to List(T2)? One example might be when implementing an interface. you might need to expose a collection of other interfaces (or maybe the same interface), But you usually hold the concrete type implementing the interface in the collection. Lets look at the following example:

Continue Reading...

I know that when you read the title you said “What is he talking about? Its easy”. Well it turns out that its not that easy. It took me a while to collect and create this, but here it is: a PHP code that converts minutes to hours. <?php function ConvertMinutes2Hours($Minutes) { if ($Minutes < […]

Continue Reading...