Skip to content

Datagrid ArgumentOutOfRangeException #2852

Description

@jbooth88

Bug explanation

I have a view model structure (simplified) as follows:

public sealed class Parent
{
    public ReadOnlyObservableCollection<Child> Children { get; init; }
    public bool IsSelected { get; set; }
}
public sealed class Child 
{
    public Parent MyParent { get; init; }

    public bool IsSelected { get; set; }
}

I have xaml for a DataGrid as follows (simplified version):

<DataGrid 
    ItemsSource="{Binding Parents, IsAsync=True}" 
    AutoGenerateColumns="False"
    RowDetailsVisibilityMode="Visible"
    >
    <DataGrid.Columns>
        <DataGridCheckBoxColumn Header="IsSelected" Binding="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsThreeState="False" SortMemberPath="IsSelected" IsReadOnly="False" />
        <DataGridTextColumn Header="Parent ID" Binding="{Binding Path=., Mode=OneTime}" SortMemberPath="DisplayName" IsReadOnly="True" />
    </DataGrid.Columns>
    <DataGrid.RowDetailsTemplate>
        <DataTemplate>
            <DataGrid 
                ItemsSource="{Binding Children, Mode=OneTime}"
                AutoGenerateColumns="False"
                >
                <DataGrid.Columns>
                    <DataGridCheckBoxColumn Header="IsSelected" Binding="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsThreeState="False" SortMemberPath="IsSelected" IsReadOnly="False" />
                    <DataGridTextColumn Header="Child ID" Binding="{Binding Path=., Mode=OneTime}" SortMemberPath="DisplayName" IsReadOnly="True" />
                </DataGrid.Columns>
            </DataGrid>
        </DataTemplate>
    </DataGrid.RowDetailsTemplate>
</DataGrid>

AllowDirectEditWithoutFocus(object sender, System.Windows.Input.MouseButtonEventArgs mouseArgs)
is throwing an ArgumentOutOfRangeException when the user clicks the check box of any DataGrid that resides inside a row details template

Setting the DataGrid style to null or using EnableEditBoxAssist=False prevents the exception.

Version

4.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions