Xceed DataGrid for WPF: checkboxes need 3 clicks to change

309 Views Asked by At

I made an extremely basic DataGrid to test it out, but I immediately ran into this issue, where clicking a checkbox doesnt do anything for the first 2 clicks. It looks like it takes a click to click off whatever it was on, 1 more click to focus before it can actually check it with the third click.

This is the DataGrid I'm using btw (https://xceed.com/xceed-datagrid-for-wpf/).

GIF showing issue

XAML:

<UserControl.Resources>
    <DataTemplate x:Key="ItemTemplate">
        <StackPanel>
            <TextBlock Text="{Binding Property1}"/>
            <CheckBox IsChecked="{Binding Property2}"/>
        </StackPanel>
    </DataTemplate>
</UserControl.Resources>
<Grid>
    <xcdg:DataGridControl ItemTemplate="{DynamicResource ItemTemplate}" 
                          ItemsSource="{Binding Collection, Source={StaticResource SampleDataSource1}}" 
                          UpdateSourceTrigger="CellContentChanged"
                          Margin="10">
    </xcdg:DataGridControl>
</Grid>

The "SampleDataSource1" is just autogenerated but here it is anyway:

<SampleDataSource1:SampleDataSource1 xmlns:SampleDataSource1="clr-namespace:Expression.Blend.SampleData.SampleDataSource1">
<SampleDataSource1:SampleDataSource1.Collection>
    <SampleDataSource1:Item Property1="Cras aenean" Property2="True"/>
    <SampleDataSource1:Item Property1="Class mauris aliquam" Property2="False"/>
    <SampleDataSource1:Item Property1="Maecenas integer duis curae" Property2="True"/>
    <SampleDataSource1:Item Property1="Praesent nullam nunc" Property2="False"/>
    <SampleDataSource1:Item Property1="Nam quisque" Property2="True"/>
    <SampleDataSource1:Item Property1="Sed accumsan" Property2="False"/>
    <SampleDataSource1:Item Property1="Aptent vivamus aliquam aliquet" Property2="True"/>
    <SampleDataSource1:Item Property1="Blandit donec dis" Property2="False"/>
    <SampleDataSource1:Item Property1="Amet commodo" Property2="True"/>
    <SampleDataSource1:Item Property1="Ante conubia" Property2="False"/>
</SampleDataSource1:SampleDataSource1.Collection>

2

There are 2 best solutions below

0
Hjalte Tagmose On BEST ANSWER

So, if you're lucky you'll see a big splash in your design window with a button that says: "Show configuration window" (which seems to disappear forever after using it). With that I generated some XAML to fix this issue:

    <xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource cvsSongs}}"
                          NavigationBehavior="RowOrCell" 
                          CellEditorDisplayConditions="RowIsBeingEdited, MouseOverCell, 
                          MouseOverRow, RowIsCurrent, CellIsCurrent" 
                          EditTriggers="BeginEditCommand, ClickOnCurrentCell, SingleClick, 
                          CellIsCurrent, ActivationGesture, RowIsCurrent"/>

If you know how to make that window appear once again feel free to comment.

Configuration Window info: Xceed documentation

Also some other people with Configuration Window problems. Might work for you: xceed forums

5
stuicidle On

on your dataGrid add this (in the xaml):

DataGridCell.GotFocus="DataGrid_GotFocus"  

and in the code behind add this:

private void DataGrid_GotFocus(object sender, RoutedEventArgs e)
{
    // Lookup for the source to be DataGridCell
    if (e.OriginalSource.GetType() == typeof(DataGridCell))
    {
        // Starts the Edit on the row;
        DataGrid grd = (DataGrid)sender;
        grd.BeginEdit(e);
    }
}