3

xml:データグリッドのボタン

<DataGridTemplateColumn Header="Update">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <Button Content="Update" Name="btnEmpGridUpdate" Tag="{Binding Path = EMPID}" Click="btnEmpGridUpdate_Click" ></Button>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

ボタンイベントのコード:

Object Id = new Object();
Id =  ((Button)sender).Tag;

これは、選択した行のすべてのセルの値を取得するための可能な方法ですか?の場合、どうすればこれを行うことができますか?または、datagridからデータセットを更新する別の方法を提案してください。前もって感謝します 。:)

4

1 に答える 1

2

これらのヘルパー関数を使用してください。 http://techiethings.blogspot.com/2010/05/get-wpf-datagrid-row-and-cell.html

[更新]ボタンでClickイベントをフックし、ハンドラーで次のようにします。

//youll need to google for GetVisualParent function.
DataGridRow row = GetVisualParent<DataGridRow>(button);
for(int j = 0; j < dataGrid.Columns.Count; j++)
   DataGridCell cell = GetCell(dataGrid, row, j);

私はあなたが何をしたいのか完全には理解していませんでしたが、これは役立つはずです。

于 2012-07-22T15:05:07.417 に答える