I have a GridViewSelectColumn in my grid. I need to set the IsEnabled value of the checkbox based on a boolean value in the row data. So something like
myCheckBox.IsEnabled = myData.IsChecked
At first I thought I could just bind the column, but it doesn't work that way, you can't bind a column to row data, i.e.
<grid:GridViewSelectColumn IsEnabled="{Binding IsChecked}" />
My next thought was to use the RowLoaded event. This might be the right way to go, but it doesn't seem to be loading every time the data is refreshed, and that's important, as we refresh often.
private void WorklistGrid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
StudyData data = e.DataElement as StudyData;
GridViewRow row = e.Row as GridViewRow;
if (data == null || row == null)
{
return;
}
var cell = e.Row.Cells[0];
var checkbox = cell.ChildrenOfType<CheckBox>();
checkbox[0].IsEnabled = data.IsChecked;
}
Maybe I'm just doing this wrong? Any suggestions?
myCheckBox.IsEnabled = myData.IsChecked
At first I thought I could just bind the column, but it doesn't work that way, you can't bind a column to row data, i.e.
<grid:GridViewSelectColumn IsEnabled="{Binding IsChecked}" />
My next thought was to use the RowLoaded event. This might be the right way to go, but it doesn't seem to be loading every time the data is refreshed, and that's important, as we refresh often.
private void WorklistGrid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
StudyData data = e.DataElement as StudyData;
GridViewRow row = e.Row as GridViewRow;
if (data == null || row == null)
{
return;
}
var cell = e.Row.Cells[0];
var checkbox = cell.ChildrenOfType<CheckBox>();
checkbox[0].IsEnabled = data.IsChecked;
}
Maybe I'm just doing this wrong? Any suggestions?