Mega Code Archive
Convert contents of a ListBoxItem to an instance of Thickness by using the BrushConverter
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();
}
}
}