--- title: "How to: Create and Use a GridLengthConverter Object" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "Grid control [WPF], creating [WPF], GridLengthConverter objects" ms.assetid: 5ab75911-e36a-4825-80e4-081c57e8e182 --- # How to: Create and Use a GridLengthConverter Object ## Example The following example shows how to create and use an instance of . The example defines a custom method called `changeCol`, which passes the to a that converts the of a to an instance of . The converted value is then passed back as the value of the property of the element. The example also defines a second custom method, called `changeColVal`. This custom method converts the of a to a and then passes that value back to the as the of the element. Note that a separate [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] file defines the contents of a . [!code-csharp[gridlengthConverterGrid#1](~/samples/snippets/csharp/VS_Snippets_Wpf/gridlengthConverterGrid/CSharp/Window1.xaml.cs#1)] [!code-vb[gridlengthConverterGrid#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/gridlengthConverterGrid/VisualBasic/Window1.xaml.vb#1)] ## See also - -