xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="GridLengthConverter_grid.Window1" Title="GridLengthConverter Sample" WindowState="Maximized"> Column 0, Row 0 Column 1, Row 0 Column 2, Row 0 Column 0, Row 1 Column 1, Row 1 Column 2, Row 1 Column 0, Row 2 Column 1, Row 2 Column 2, Row 2 25 50 75 100 125 150 25 50 75 100 125 150 Set MinWidth="100" Set MaxWidth="125" Set MinHeight="50" Set MaxHeight="75" //File:Window.xaml.cs using System; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; namespace GridLengthConverter_grid { public partial class Window1 : Window { public void changeRowVal(object sender, RoutedEventArgs e) { txt2.Text = "Current Grid Row is " + hs2.Value.ToString(); } public void changeColVal(object sender, RoutedEventArgs e) { txt1.Text = "Current Grid Column is " + hs1.Value.ToString(); } public void changeCol(object sender, SelectionChangedEventArgs args) { ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem); GridLengthConverter myGridLengthConverter = new GridLengthConverter(); if (hs1.Value == 0) { GridLength gl1 = (GridLength)myGridLengthConverter.ConvertFromString(li.Content.ToString()); col1.Width = gl1; } else if (hs1.Value == 1) { GridLength gl2 = (GridLength)myGridLengthConverter.ConvertFromString(li.Content.ToString()); col2.Width = gl2; } else if (hs1.Value == 2) { GridLength gl3 = (GridLength)myGridLengthConverter.ConvertFromString(li.Content.ToString()); col3.Width = gl3; } } public void changeRow(object sender, SelectionChangedEventArgs args) { ListBoxItem li2 = ((sender as ListBox).SelectedItem as ListBoxItem); GridLengthConverter myGridLengthConverter2 = new GridLengthConverter(); if (hs2.Value == 0) { GridLength gl4 = (GridLength)myGridLengthConverter2.ConvertFromString(li2.Content.ToString()); row1.Height = gl4; } else if (hs2.Value == 1) { GridLength gl5 = (GridLength)myGridLengthConverter2.ConvertFromString(li2.Content.ToString()); row2.Height = gl5; } else if (hs2.Value == 2) { GridLength gl6 = (GridLength)myGridLengthConverter2.ConvertFromString(li2.Content.ToString()); row3.Height = gl6; } } public void setMinWidth(object sender, RoutedEventArgs e) { col1.MinWidth = 100; col2.MinWidth = 100; col3.MinWidth = 100; } public void setMaxWidth(object sender, RoutedEventArgs e) { col1.MaxWidth = 125; col2.MaxWidth = 125; col3.MaxWidth = 125; } public void setMinHeight(object sender, RoutedEventArgs e) { row1.MinHeight = 50; row2.MinHeight = 50; row3.MinHeight = 50; } public void setMaxHeight(object sender, RoutedEventArgs e) { row1.MaxHeight = 75; row2.MaxHeight = 75; row3.MaxHeight = 75; } } }