c# - Retrieve column name from a gridcontrol in mvvm design -


hi working on wpf project in have grid control . itemssource property of grid control bound datatable in viewmodel. following mvvm pattern, question need bind selectedcell property of grid control property in view model class. possible determine name of column in cell resides binding property in view model class. know event handler can attached cell call function in code behind view, dont wish follow approach since not mvvm. kindly me suggestions.

in xaml bind currentcell property datagridcellinfo in view model:

<datagrid selectionunit="cell"           selectionmode="single"           itemssource="{binding mydatatable}"           currentcell="{binding selectedcellinfo, mode=onewaytosource}"/> 

then in view model can access header bound object:

public datagridcellinfo selectedcellinfo {     { return _selectedcellinfo; }     set     {         _selectedcellinfo = value;         onpropertychanged("selectedcellinfo");         _columnname = _selectedcellinfo.column.header;     } } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -