Arsen Zahray
Arsen Zahray

Reputation: 25367

How to bind to the ItemsSource of a DataDrid from inside DataRow?

I'm working with a window with several DataGrid's, and I'd like to process deletion event via a single command.

For this, I need to pass to that command the list of records, from which the record has to be deleted.

Here's what I mean:

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

How do I bind from inside <Button Content="delete" to ItemsSource of the DataGrid?

Upvotes: 1

Views: 308

Answers (1)

brunnerh
brunnerh

Reputation: 185553

Something like

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

Upvotes: 2

Related Questions