I've a DataGrid
defined as follow:
private void CreateSemanticChannels()
{
myGrid.Style = (Style)FindResource("MyDataGrid");
var col1 = new DataGridTextColumn
{
Header = "FUNCTIONALITY",
Binding = new Binding("Functionality"),
};
myGrid.Columns.Add(col1);
var col2 = new DataGridTextColumn
{
Header = "ASSOCIATED TO",
Binding = new Binding("AssociatedTo"),
FontWeight = FontWeights.SemiBold
};
myGrid.Columns.Add(col2);
DataTemplate buttonTemplate = new DataTemplate();
FrameworkElementFactory buttonFactory = new FrameworkElementFactory(typeof(Button));
buttonTemplate.VisualTree = buttonFactory;
var col3 = new DataGridTemplateColumn
{
Header = "STATUS",
CellTemplate = buttonTemplate
};
myGrid.Columns.Add(col3);
// AGGIORNAMENTO CONTENUTO E VISUALIZZAZIONE
UpdateGrid();
myGrid.SelectedIndex = -1;
advSettingGrid.Children.Add(myGrid);
}
Where in UpdateGrid
I add the item to the DataGrid.
myGrid.Items.Add(newRecord)
;
I want to modify the Style
of each Button
so I have started following this post but I have always ItemSource
empty.
I read this, and actually I forgot to set the ItemSource
property. So I defined the List
of my object as _recordList
and in the XAML I added this property
<Setter Property="BindingGroup" Value="{Binding Path=_recordList}"></Setter>
However, I still have ItemSource empty.
Any help is really appreciate!