1

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>

Hjalte Tagmose
  • 67
  • 1
  • 12

2 Answers2

0

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);
    }
}
stuicidle
  • 297
  • 1
  • 8
  • Thanks for the quick answer, but it doesnt work? There's no difference, so I'm getting the feeling that it doesn't reach the function or something. IntelliSense recognizes it and everything. No errors. I'm a bit of a noob, could I be missing something? – Hjalte Tagmose Aug 16 '17 at 13:43
  • I had the same issue but with combo boxes in a data grid and this is how I solved it, though it would work appologies :) – stuicidle Aug 16 '17 at 14:14
  • Have you tried putting a break point in the DataGrid_GotFocus method, just to see if it gets called? – stuicidle Aug 16 '17 at 14:21
  • Yeah it is called, but makes no difference in the interaction.. weird. Thanks for trying though, might be helpful in finding the solution :). – Hjalte Tagmose Aug 21 '17 at 06:41
  • I was just wondering if DataGridCell is the right type in these circumstances – stuicidle Aug 21 '17 at 08:03
0

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

Hjalte Tagmose
  • 67
  • 1
  • 12