This documentation is archived and is not being maintained.

ThicknessConverter Class

Converts instances of other types to and from instances of Thickness.

Namespace: System.Windows
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

'Declaration
Public Class ThicknessConverter
	Inherits TypeConverter
'Usage
Dim instance As ThicknessConverter

public class ThicknessConverter extends TypeConverter
public class ThicknessConverter extends TypeConverter
<ThicknessConverter .../>

This example shows how to create an instance of ThicknessConverter and use it to change the thickness of a border.

The example defines a custom method called changeThickness; this method first converts the contents of a ListBoxItem, as defined in a separate Extensible Application Markup Language (XAML) file, to an instance of Thickness, and later converts the content into a String. This method passes the ListBoxItem to a ThicknessConverter object, which converts the Content of a ListBoxItem to an instance of Thickness. This value is then passed back as the value of the BorderThickness property of the Border.

This example does not run. For the complete sample, see ThicknessConverter Object Sample.

Public Sub changeThickness(ByVal sender As Object, ByVal args As SelectionChangedEventArgs)

    Dim li As ListBoxItem = CType(CType(sender, ListBox).SelectedItem, ListBoxItem)
    Dim myThicknessConverter As System.Windows.ThicknessConverter = New System.Windows.ThicknessConverter()
    Dim th1 As Thickness = CType(myThicknessConverter.ConvertFromString(li.Content.ToString()), Thickness)
    border1.BorderThickness = th1
    bThickness.Text = "Border.BorderThickness =" + li.Content.ToString()
End Sub

System.Object
   System.ComponentModel.TypeConverter
    System.Windows.ThicknessConverter

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: