Mega Code Archive
Convert contents of a ListBoxItem to an instance of Thickness by using the ThicknessConverter
ThicknessConverter Sample
Change the BorderThickness Property:
0
5
10
15
20
25
30
35
40
45
50
//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 changeThickness(object sender, SelectionChangedEventArgs args)
{
ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
ThicknessConverter myThicknessConverter = new ThicknessConverter();
Thickness th1 = (Thickness)myThicknessConverter.ConvertFromString(li.Content.ToString());
border1.BorderThickness = th1;
bThickness.Text = "Border.BorderThickness =" + li.Content.ToString();
}
}
}