--- 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 property programmatically. Three elements are placed within a element in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)]. Each event for a corresponds with an event handler in the code. The event handlers use the same name as the value they will apply to `txt2` when the button is clicked. Also, the text in `txt1` (a not shown in the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)]) 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 - -