1

We have an observable collection that consists of a custom class called Row which is used as itemsource in our Datagrid. The Row class itself consists of 3 different cell types.

public class Row
{

    public TimeCell TimeCell { get; set; }
    public PositionsCell PositionsCell { get; set; }
    public TemperatureCell TempCell { get; set; }
}

These cell types all have the parent class Cell which contains the majority of properties. Our Datagrid consists of template columns representing each of the cells in Row with relevant bindings. The problem is that when we do Datagrid Selecteditem we currently get a Model.Row returned whereas we would like to get the cell directly (Model.Row.TimeCell) for example if a cell in that column was clicked/selected. How can we achieve this?

1 Answers1

0

You Need to cast DataGrid.SelectedItem To your custom class item i.e.

Row selRow = mainDataGrid.SelectedItem as Row;

Now you can able to access properties of Row i.e.

TimeCell timeCell = selRow.TimeCell;

Hope this will work

Thanks for letting us help you