* 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
1.6 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Change the TextWrapping Property Programmatically | 03/30/2017 |
|
|
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-xamlTextWrapProperty#1]
[!code-csharpTextWrapProperty#2] [!code-vbTextWrapProperty#2]