DataGrid itemSource绑定为空

时间:2016-06-14 14:06:56

标签: c# wpf xaml datagrid

我的DataGrid定义如下:

 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);

    }

UpdateGrid中的哪个位置我将该项添加到DataGrid。

myGrid.Items.Add(newRecord);

我想修改每个Style的{​​{1}},因此我开始关注此Same height of logo and navbar,但我始终Button为空。

我看了post,实际上我忘了设置ItemSource属性。所以我将对象的ItemSource定义为List,并在XAML中添加了此属性

_recordList

但是,我仍然将ItemSource清空。

任何帮助都非常感谢!

0 个答案:

没有答案