I have a column with a celltemplate and celleditingtemplate with a bound checkbox (in order to allow the user to click once to edit). I would like to get the row into edit mode at the same time. So in the checkbox click event I am attempting this, but the current row of the grid changes to the next row and it does not enter edit mode. If I set a break point on BeginEdit() to delay its execution then it works. I tried to use Dispatcher.BeginInvoke for the BeginEdit call, but that is not working. Here is a snippet:
<telerik:GridViewDataColumn Header="Active" EditTriggers="CellClick">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center" Click="CheckBox_Click" IsChecked="{Binding Active, Mode=TwoWay}" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
<telerik:GridViewDataColumn.CellEditTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center" IsChecked="{Binding Active, Mode=TwoWay}" />
</DataTemplate>
</telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
var cb = sender as CheckBox;
var r = cb.ParentOfType<GridViewRow>();
var c = cb.ParentOfType<GridViewCell>();
r.IsSelected = true;
this.Dispatcher.BeginInvoke(() =>
{
grd.BeginEdit();
});
}
Marty
<telerik:GridViewDataColumn Header="Active" EditTriggers="CellClick">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center" Click="CheckBox_Click" IsChecked="{Binding Active, Mode=TwoWay}" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
<telerik:GridViewDataColumn.CellEditTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center" IsChecked="{Binding Active, Mode=TwoWay}" />
</DataTemplate>
</telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
var cb = sender as CheckBox;
var r = cb.ParentOfType<GridViewRow>();
var c = cb.ParentOfType<GridViewCell>();
r.IsSelected = true;
this.Dispatcher.BeginInvoke(() =>
{
grd.BeginEdit();
});
}