내보내기(0) 인쇄
모두 확장

ThicknessConverter 클래스

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

네임스페이스: System.Windows
어셈블리: PresentationFramework(presentationframework.dll)
XML 네임스페이스:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public class ThicknessConverter : TypeConverter
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 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();
}

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

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

Microsoft .NET Framework 3.0은 Windows Vista, Microsoft Windows XP SP2 및 Windows Server 2003 SP1에서 지원됩니다.

.NET Framework

3.0에서 지원

커뮤니티 추가 항목

추가
표시:
© 2015 Microsoft