【问题标题】:How to bind to the ItemsSource of a DataDrid from inside DataRow?如何从 DataRow 内部绑定到 DataGrid 的 ItemsSource?
【发布时间】:2023-03-08 15:20:02
【问题描述】:

我正在处理一个包含多个 DataGrid 的窗口,我想通过单个命令处理删除事件。

为此,我需要将记录列表传递给该命令,必须从中删除记录。

这就是我的意思:

<DataGrid  Margin="0" HeadersVisibility="None" 
     ItemsSource="{Binding GroupExtednedDataList}" 
     ... >
        <DataGrid.Columns>
            <DataGridTemplateColumn>
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Button Content="delete" 
           CommandParameter="{Binding::: 
          How do I bind from here to GroupExtednedDataList from ItemsSoruce?}" >
                        </Button>
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

        </DataGrid.Columns>
    </DataGrid>

如何从 &lt;Button Content="delete" 内部绑定到 DataGrid 的 ItemsSource?

【问题讨论】:

    标签: c# wpf xaml data-binding datagrid


    【解决方案1】:

    类似

    {Binding ItemsSource, RelativeSource={RelativeSource AncestorType=DataGrid}}
    

    【讨论】:

      猜你喜欢
      • 2016-11-05
      • 1970-01-01
      • 2013-01-14
      • 1970-01-01
      • 2019-03-23
      • 2015-11-22
      • 1970-01-01
      • 2011-12-17
      • 1970-01-01
      相关资源
      最近更新 更多