mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-07 23:43:19 +02:00
* net-current-v30plus-md.md * net-current-v40plus-md.md * tla2sharptla-ui-md.md * tla2sharptla-uiautomation-md.md * tla2sharptla-winclient-md.md * tla2sharptla-xaml-md.md * tlasharptla-ui-md.md * tlasharptla-uiautomation-md.md * tlasharptla-winclient-md.md * tlasharptla-xaml-md.md * fix warnings
33 lines
1.9 KiB
Markdown
33 lines
1.9 KiB
Markdown
---
|
|
title: "How to: Use a ThicknessConverter Object"
|
|
ms.date: "03/30/2017"
|
|
dev_langs:
|
|
- "csharp"
|
|
- "vb"
|
|
helpviewer_keywords:
|
|
- "border thickness [WPF]"
|
|
- "ThicknessConverter objects [WPF]"
|
|
ms.assetid: 52682194-d7fd-499c-8005-73fcc84e7b2c
|
|
---
|
|
# How to: Use a ThicknessConverter Object
|
|
|
|
## Example
|
|
|
|
This example shows how to create an instance of <xref:System.Windows.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 <xref:System.Windows.Controls.ListBoxItem>, as defined in a separate Extensible Application Markup Language (XAML) file, to an instance of <xref:System.Windows.Thickness>, and later converts the content into a <xref:System.String>. This method passes the <xref:System.Windows.Controls.ListBoxItem> to a <xref:System.Windows.ThicknessConverter> object, which converts the <xref:System.Windows.Controls.ContentControl.Content%2A> of a <xref:System.Windows.Controls.ListBoxItem> to an instance of <xref:System.Windows.Thickness>. This value is then passed back as the value of the <xref:System.Windows.Controls.Border.BorderThickness%2A> property of the <xref:System.Windows.Controls.Border>.
|
|
|
|
This example does not run.
|
|
|
|
[!code-csharp[ThicknessConverter#1](~/samples/snippets/csharp/VS_Snippets_Wpf/ThicknessConverter/CSharp/Window1.xaml.cs#1)]
|
|
[!code-vb[ThicknessConverter#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ThicknessConverter/VisualBasic/Window1.xaml.vb#1)]
|
|
|
|
## See also
|
|
|
|
- <xref:System.Windows.Thickness>
|
|
- <xref:System.Windows.ThicknessConverter>
|
|
- <xref:System.Windows.Controls.Border>
|
|
- [How to: Change the Margin Property](/previous-versions/dotnet/netframework-3.5/ms750561(v=vs.90))
|
|
- [How to: Convert a ListBoxItem to a new Data Type](/previous-versions/dotnet/netframework-3.5/ms749147(v=vs.90))
|
|
- [Panels Overview](../controls/panels-overview.md)
|