mvvm - WPF Datagrid header binding for custom columns not getting working -


I'm trying to create a label and custom columns with a Knboboks column headers. For the first time the grid is loaded properly. On the click of a button, I change the itmesources of the datagrid. I see that the datagrid cells are being updated, but not the header. I also see that the datagrid_loaded is not being called. I've found that the " binding " object debugging I binding path supply, but Header of I Source < / Strong>, so headers do not get the update how to supply the path for the header so that its binding ?

  Private zero datagrid_loaded (object sender, RoutedEventArgs e) {DataGrid grid = sender as data grid; If (grid item number == 0) {return; } StageVM data = grid. As StageVM [0]; If (data == empty) {return; } Int index = 0; Forec (Stage Aitimmm ultimate) in Detakstej {var binding = new Binding (Stringkformet ( "Stage [{0}. Stejitm. Value" index)); Grid Colm.ad (new Kstmbound column) (Kanusarsort = false, Hedertampletsiyntrk = Yhkfndersors ( "column as headers Taimplet selector Detatampletshiplr as"), header style = Hekfndersors ( "Stejhader stele") style, headers = (New binding). Source = Param.StageItem.Key), binding = binding, blueprint selectorname = "sterezange column template selector"}); Index ++; }}  

and customBoundColumn class is as follows:

  public class CustomBoundColumn: DataGridBoundColumn {public string TemplateSelectorName {get; Set; } Protected override Element generated Framework Element (Detagreed cell, object Detaitm) {var binding = new Binding ((binding) Binding) .Path.Path); Binding Source = datatum; Var content = new content control (); Content.ContentTemplateSelector = (DataTemplateSelector) cell.FindResource (TemplateSelectorName); Content.SetBinding (ContentControl.ContentProperty, Binding); Return material; } Protected Override Framework Element Generated Editing Element (Datagreat Cell Cell, Object DataTime) {Return Generated Element (Cell, Dataitum); }}  

Check that it can help you:

I had the same problem about binding datagrid headers with my ViewModel, this is a xaml based solution.


Comments