Hi,
I'm using NetAdvantage for WPF 11.1 and I added a 'selected' column to my XamDataGrid as follows:
<igDP:Field Name="IsSelected" Label="Selected"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="True" EditorType="{x:Type igEditors:XamCheckEditor}"/> </igDP:Field.Settings></igDP:Field>
(I saw this answer in one of the forums here).
My question is - when I select some items, the last selected item is not selected until the checkbox loses focus (until I click somewhere else).
Is there a way to change this behavior? It is really counter-intuitive.
Thanks.
Thanks for your example.
It seems that the problem was using the x:key for the style. After removing it (like in your example), it is working.
Thanks!
I am attaching a sample application(DataGridXamCheckEditorForceEditing.zip) that shows my suggestion and no exception appears.
Please let me know, if this is still an issue for you.
How can I add this style if my grid is defined as follows:
<igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields>
...
<igDP:Field Name="IsSelected" Label="Selected"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="{Binding IsEditable}" EditorType="{x:Type igEditors:XamCheckEditor}" LabelPresenterStyle="{StaticResource CheckBoxedHeaderStyle}" /> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields>
my resources:
<igDP:XamDataGrid.Resources> <Style x:Key="CheckBoxedHeaderStyle" TargetType="{x:Type igDP:LabelPresenter}"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <CheckBox Name="HeaderCheckBox" Content="{Binding}" Click="OnClick" IsChecked="True" IsThreeState="True"/> </DataTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="XamCheckBoxStyle" TargetType="igEditors:XamCheckEditor"> <EventSetter Event="ValueChanged" Handler="XamCheckEditorValueChanged"/> </Style></igDP:XamDataGrid.Resources>
When I used
<igDP:FieldSettings AllowEdit="{Binding IsEditable}" EditorType="{x:Type igEditors:XamCheckEditor}" LabelPresenterStyle="{StaticResource CheckBoxedHeaderStyle}" EditorStyle="XamCheckBoxStyle"/>
I got a runtime exception.
Hello,
Thank you for your post. The underlying data object is updated when the editor exits edit mode or loses focus. If you want to update it immediately after you change the value, you have to handle the Value Changed (Checked/Unchecked) event of the XamCheckEditor(CheckBox) and force it to exist edit mode by calling EndEditMode(...) method like e.g. :
<Style TargetType="igEditors:XamCheckEditor">
<EventSetter Event="ValueChanged" Handler="XamCheckEditor_ValueChanged"/>
</Style>
…
private void XamCheckEditor_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
XamCheckEditor editor = sender as XamCheckEditor;
editor.EndEditMode(true, true);
}
If you need any further assistance on this matter, feel free to ask.