mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-06 16:06:07 +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
27 lines
1.6 KiB
Markdown
27 lines
1.6 KiB
Markdown
---
|
|
title: "How to: Change the TextWrapping Property Programmatically"
|
|
ms.date: "03/30/2017"
|
|
dev_langs:
|
|
- "csharp"
|
|
- "vb"
|
|
helpviewer_keywords:
|
|
- "documents [WPF], changing TextWrapping property programmatically"
|
|
- "TextWrapping property [WPF], changing programmatically"
|
|
ms.assetid: 30d25554-4c82-4df9-a8d6-35683a4a13bb
|
|
---
|
|
# How to: Change the TextWrapping Property Programmatically
|
|
## Example
|
|
The following code example shows how to change the value of the <xref:System.Windows.Controls.TextBlock.TextWrapping%2A> property programmatically.
|
|
|
|
Three <xref:System.Windows.Controls.Button> elements are placed within a <xref:System.Windows.Controls.StackPanel> element in XAML. Each <xref:System.Windows.Controls.Primitives.ButtonBase.Click> event for a <xref:System.Windows.Controls.Button> corresponds with an event handler in the code. The event handlers use the same name as the <xref:System.Windows.Controls.TextBlock.TextWrapping%2A> value they will apply to `txt2` when the button is clicked. Also, the text in `txt1` (a <xref:System.Windows.Controls.TextBlock> not shown in the XAML) is updated to reflect the change in the property.
|
|
|
|
[!code-xaml[TextWrapProperty#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/TextWrapProperty/VisualBasic/Pane1.xaml#1)]
|
|
|
|
[!code-csharp[TextWrapProperty#2](~/samples/snippets/csharp/VS_Snippets_Wpf/TextWrapProperty/CSharp/Window1.xaml.cs#2)]
|
|
[!code-vb[TextWrapProperty#2](~/samples/snippets/visualbasic/VS_Snippets_Wpf/TextWrapProperty/VisualBasic/Pane1.xaml.vb#2)]
|
|
|
|
## See also
|
|
|
|
- <xref:System.Windows.Controls.TextBlock.TextWrapping%2A>
|
|
- <xref:System.Windows.TextWrapping>
|