Hi,
in my xamGrid i have a templatecolumn with a checkbox in it and a textcolumn. The textcolumn should be editable the whole time until the checkbox is checked. If the checkbox is not checked the textcolumn should return to edit mode.
How can i achieve this?
Thanks in advance
I'm not exactly sure what you're trying to achieve. If I understand you correctly, you might try checking the value of the checkbox in CellExitingEditMode event and cancel the operation if the checkbox is not checked. Assuming your TemplateColumn is bound to a boolean property in your data object, the code should look something like this:
private void igGrid_CellExitingEditMode(object sender, ExitEditingCellEventArgs e)
{
if (e.Cell.Column.Key == "MyTextColumnKey")
e.Cancel = !((MyDataObject)e.Cell.Row.Data).MyBoolProperty;
}
Hope that helps,
Like i said while in editing mode i can't do anything except editing the cell. But i would like to change other data AND hold the cell in editing mode until i check the box.
my shortened xaml
<ig:XamGrid ItemsSource="{Binding ArticleAttributeModels, UpdateSourceTrigger=Default}" AutoGenerateColumns="False" x:FieldModifier="private" Name="articleList" CellExitingEditMode="articleList_CellExitingEditMode"> <ig:XamGrid.Columns> <TextColumns ...> <ig:ColumnLayout Key="Attributes" AutoGenerateColumns="False"> <ig:ColumnLayout.Columns> <ig:TemplateColumn Key="AttributeModel.Attribute" > <ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding AttributeModel.Attribute}" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> </ig:TemplateColumn> <ig:TemplateColumn Key="AttributeModel.Measure" > <ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding AttributeModel.Measure}" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> </ig:TemplateColumn> <ig:TemplateColumn Key="AttributeModel.Value" > <ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding AttributeModel.Value}" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> <ig:TemplateColumn.EditorTemplate> <DataTemplate> <Editors:XamComboEditor IsEditable="True" ItemsSource="{Binding SuggestedValues}" /> </DataTemplate> </ig:TemplateColumn.EditorTemplate> </ig:TemplateColumn> <ig:TemplateColumn Key="Status" > <ig:TemplateColumn.ItemTemplate> <DataTemplate> <CheckBox IsChecked="{Binding Status}" Checked="Status_Checked" Unchecked="Status_Unchecked"/> </DataTemplate> </ig:TemplateColumn.ItemTemplate> <ig:TemplateColumn.EditorTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="Score:" /> <TextBlock Text="{Binding Score}" Margin="3,0" /> <CheckBox IsChecked="{Binding Status}" Checked="Status_Checked" Unchecked="Status_Unchecked"/> </StackPanel> </DataTemplate> </ig:TemplateColumn.EditorTemplate> </ig:TemplateColumn> </ig:ColumnLayout.Columns> <ig:ColumnLayout.EditingSettings> <ig:EditingSettingsOverride AllowEditing="Cell" /> </ig:ColumnLayout.EditingSettings>
my shortened c# code
private void Status_Checked(object sender, RoutedEventArgs e) { articleList.ExitEditMode(true); } private void Status_Unchecked(object sender, RoutedEventArgs e) { articleList.EnterEditMode(articleList.ActiveCell.Row.Cells[2]); } private void articleList_CellExitingEditMode(object sender, ExitEditingCellEventArgs e) { if (e.Cell.Column.Key == "AttributeModel.Value") { e.Cancel = (bool)e.Cell.Row.Cells[3].Value; } }
In a perfect world my xamgrid should change the look of the cell with the key "Status" and should make the cell with the key "Value" editable / not editable if the user presses the checkbox.