What is the code behind for datagridtemplatecolumn, and how to use it?

use this: DataGridTemplateColumn col1 = new DataGridTemplateColumn(); col1.Header = “MyHeader”; FrameworkElementFactory factory1 = new FrameworkElementFactory(typeof(CheckBox)); Binding b1 = new Binding(“IsSelected”); b1.Mode = BindingMode.TwoWay; factory1.SetValue(CheckBox.IsCheckedProperty, b1); factory1.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(chkSelect_Checked)); DataTemplate cellTemplate1 = new DataTemplate(); cellTemplate1.VisualTree = factory1; col1.CellTemplate = cellTemplate1; dgTransportReqsts.DataGrid.Columns.Add(col1); I used this to add CheckBox in my DataGridTemplateColumn at runtime. Hope this helps!!

How to access datagrid template column textbox text WPF C#

To find a control in a DataGrid template column, you should use FindChild(): public static T FindChild<T>(DependencyObject parent, string childName) where T : DependencyObject { if (parent == null) { return null; } T foundChild = null; int childrenCount = VisualTreeHelper.GetChildrenCount(parent); for (int i = 0; i < childrenCount; i++) { var child = VisualTreeHelper.GetChild(parent, … Read more