WPF C# Tutorial

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ThicknessConverter_Csharp.Window1"
    Title="ThicknessConverter Sample">
  
    
      ThicknessConverter Sample
    
      
        
          
        

        
        
      
    
    
      
        
      

      
        
      

      Set the BorderBrush Property:
      
        Red
        Green
        Blue
        Yellow
        Orange
        Purple
        Silver
        Pink
        Maroon
        Brown
        Black
      
    
          

//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Media;
namespace ThicknessConverter_Csharp
{
  public partial class Window1 : Window
  {
    public void changeColor(object sender, SelectionChangedEventArgs args)
    {
      ListBoxItem li2 = ((sender as ListBox).SelectedItem as ListBoxItem);
            BrushConverter myBrushConverter = new BrushConverter();
            border1.BorderBrush = (Brush)myBrushConverter.ConvertFromString((string)li2.Content);
            bColor.Text = "Border.Borderbrush =" + li2.Content.ToString();
        }
  }
}