Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datagrid ArgumentOutOfRangeException #2852

Closed
jbooth88 opened this issue Sep 15, 2022 · 0 comments · Fixed by #2902
Closed

Datagrid ArgumentOutOfRangeException #2852

jbooth88 opened this issue Sep 15, 2022 · 0 comments · Fixed by #2902
Labels
Milestone

Comments

@jbooth88
Copy link

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

@jbooth88 jbooth88 added bug evaluation required Items is pending review or evaluation by the team labels Sep 15, 2022
@Keboo Keboo removed the evaluation required Items is pending review or evaluation by the team label Oct 6, 2022
Keboo added a commit to Keboo/MaterialDesignInXamlToolkit that referenced this issue Oct 6, 2022
@Keboo Keboo added this to the 4.7.0 milestone Oct 6, 2022
Keboo added a commit that referenced this issue Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants