How to use ThicknessConverter in WPF

ThicknessConverter is used to convert some content to a Thickness.

The following code snippet reads a ListBox item and changes its value to a Thickness and sets Thickness of a Border.

 private 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();
}