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

System.NullReferenceException when using snap layouts while loading data #9682

Open
alraseensaad opened this issue Aug 30, 2024 · 2 comments
Labels
Investigate Requires further investigation by the WPF team.

Comments

@alraseensaad
Copy link

Description

this my code

<GroupBox Grid.Row="1"
          Margin="0,10"
          Padding="0,5"
          Header="{x:Static Lang:Resources.Details}">
    <Grid Grid.IsSharedSizeScope="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <DataGrid x:Name="datagrid"
                  Grid.Row="0"
                  Margin="0"
                  Padding="0,0,0,0"
                  AutoGenerateColumns="False"
                  ColumnWidth="*"
                  d:MinColumnWidth="90"
                  GridLinesVisibility="None"
                  CanUserAddRows="False"
                  ItemsSource="{Binding DoubleEntry.Ledgers}"
                  SelectionUnit="CellOrRowHeader"
                  SelectionMode="Extended"
                  share:DataGridVisualHelper.EnableRowsMove="True"
                  RowHeaderWidth="10"
                  EnableRowVirtualization="True"
                  EnableColumnVirtualization="True"
                  CanUserReorderColumns="True"
                  CanUserResizeColumns="True"
                  CanUserSortColumns="True"
                  VirtualizingStackPanel.VirtualizationMode="Recycling"
                  VirtualizingStackPanel.IsVirtualizing="True"
                  VirtualizingPanel.ScrollUnit="item"
                  ScrollViewer.CanContentScroll="True"
                  PreviewMouseWheel="DataGrid_PreviewMouseWheel"> 
            <DataGrid.Columns>
                <DataGridTemplateColumn x:Name="Column0"
                                        Width="auto"
                                        Header="{x:Static Lang:Resources.Accounts_Name_}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <controls:AccountComboBox x:Name="AccountsComboBox"
                                                      DisplayMemberPath="DisplayName"
                                                      IsEditable="True"
                                                      IsTextSearchCaseSensitive="True"
                                                      IsTextSearchEnabled="True"
                                                      ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=Page},Path=DataContext.GetList.Accounts}"
                                                      SelectedItem="{Binding Account,UpdateSourceTrigger=PropertyChanged}"
                                                      SelectedValue="{Binding AccountGuid, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
                                                      SelectedValuePath="Guid"
                                                      ToolTip="{Binding Account.Name,Mode=OneWay}"
                                                      Style="{StaticResource ComboBoxInDataGrid}">                   
                            </controls:AccountComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn x:Name="Column1"
                                        Width="auto"
                                        Header="{x:Static Lang:Resources.Currency_Name_}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox DisplayMemberPath="Name"
                                      IsEditable="True"
                                      IsTextSearchCaseSensitive="True"
                                      IsTextSearchEnabled="True"
                                      ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=Page},Path=DataContext.GetList.Currencies}"
                                      SelectedItem="{Binding Currency,UpdateSourceTrigger=PropertyChanged}"
                                      SelectedValue="{Binding CurrencyId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
                                      SelectedValuePath="Guid"
                                      Style="{DynamicResource ComboBoxInDataGrid}">
                                <ComboBox.InputBindings>
                                    <KeyBinding Key="F5"
                                                Command="{Binding RelativeSource={RelativeSource AncestorType=Page},Path=DataContext.UpdateCurrenciesListCommand}" />
                                </ComboBox.InputBindings>
                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn x:Name="Column2"
                                        Width="auto"
                                        Header="{x:Static Lang:Resources.Currency_Rate_}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <controls:DecimalTextBox Style="{DynamicResource ItemControlTextBox}"
                                                     Text="{Binding CurrencyRate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn x:Name="Column3"
                                        Width="auto"
                                        Header="{x:Static Lang:Resources.Debit_}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <controls:DecimalTextBox  TextWrapping="NoWrap"
                                                      HorizontalContentAlignment="Center"
                                                      ISOCurrencySymbol="{Binding Currency.ISOCurrencySymbol}"
                                                      Style="{DynamicResource ItemControlTextBox}"
                                                      Text="{Binding Debit, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn x:Name="Column4"
                                        Width="auto"
                                        Header="{x:Static Lang:Resources.Credit_}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <controls:DecimalTextBox HorizontalContentAlignment="Center"
                                                     TextWrapping="NoWrap"
                                                     ISOCurrencySymbol="{Binding Currency.ISOCurrencySymbol}"
                                                     Style="{DynamicResource ItemControlTextBox}"
                                                     Text="{Binding Credit, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn x:Name="Column5"
                                        Width="auto"
                                        Header="{x:Static Lang:Resources.EDebit_}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <controls:DecimalTextBox HorizontalContentAlignment="Center"
                                                     IsReadOnly="True"
                                                     Style="{DynamicResource ItemControlTextBox}"
                                                     Text="{Binding EquivalentDebit, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn x:Name="Column6"
                                        Width="auto"
                                        Header="{x:Static Lang:Resources.ECredit_}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <controls:DecimalTextBox HorizontalContentAlignment="Center"
                                                     IsReadOnly="True"
                                                     Style="{DynamicResource ItemControlTextBox}"
                                                     Text="{Binding EquivalentCredit, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn x:Name="Column7"
                                        Width="*"
                                        MinWidth="150"
                                        Header="{x:Static Lang:Resources.Note_}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Style="{DynamicResource ItemControlTextBox}"
                                     Text="{Binding Note,Delay=500, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
                                     TextWrapping="Wrap"
                                     AcceptsReturn="True" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn x:Name="Column8"
                                        Width="30"
                                        MinWidth="30">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Command="{Binding RelativeSource={RelativeSource AncestorType=Page}, Path=DataContext.JournalEntryDetails.RemoveLedger}"
                                    CommandParameter="{Binding}"
                                    Content="{DynamicResource DeleteIcon}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <Grid Grid.Row="1"
              Margin="0 2 0 0">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=RowHeaderWidth}" />
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=Columns[0].ActualWidth}" />
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=Columns[1].ActualWidth}" />
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=Columns[2].ActualWidth}" />
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=Columns[3].ActualWidth}" />
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=Columns[4].ActualWidth}" />
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=Columns[5].ActualWidth}" />
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=Columns[6].ActualWidth}" />
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=Columns[7].ActualWidth}" />
                <ColumnDefinition Width="{Binding ElementName=datagrid,Path=Columns[8].ActualWidth}" />
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="5"
                        Grid.ColumnSpan="2">
                <controls:DecimalTextBox  Margin="0 0 -0.5 0"
                                          Grid.Row="0"
                                          IsReadOnly="True"
                                          HorizontalAlignment="Right"
                                          MinWidth="{Binding ElementName=datagrid,Path=Columns[5].ActualWidth}"
                                          Style="{DynamicResource ItemControlTextBox}"
                                          Text="{Binding DoubleEntry.TotalDebit, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
            </StackPanel>
            <StackPanel Grid.Column="7"
                        Grid.ColumnSpan="2">
                <controls:DecimalTextBox Margin="1 0 0 0"
                                         Grid.Row="0"
                                         IsReadOnly="True"
                                         HorizontalAlignment="Left"
                                         MinWidth="{Binding ElementName=datagrid,Path=Columns[6].ActualWidth}"
                                         Style="{DynamicResource ItemControlTextBox}"
                                         Text="{Binding DoubleEntry.TotalCredit, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
            </StackPanel>
            <TextBlock Grid.Column="6"
                       Grid.ColumnSpan="2"
                       Grid.Row="1"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Center"
                       Text="{Binding DoubleEntry.Difference,Mode=OneWay}">
                <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding DoubleEntry.Difference}"
                                         Value="0">
                                <Setter Property="Visibility"
                                        Value="Collapsed" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style></TextBlock>
            <Button x:Name="AddButton"
                    Grid.Column="9"
                    Grid.Row="0"
                    Margin="0 0 -1 0"
                    Height="30"
                    VerticalAlignment="Top"
                    ToolTip="{x:Static Lang:Resources.Add_}"
                    Command="{Binding AddLedger}"
                    Content="{DynamicResource AddIcon}" />
        </Grid>
    </Grid>
</GroupBox>


### Reproduction Steps

press window + left arrow to use the snap layouts while loading data to the DataGrid 

https://github.com/user-attachments/assets/60b1e367-f676-4ca2-823d-9c5a74824905



### Expected behavior

nothing happen and divide the screen 

### Actual behavior

it throws 

System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed.
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)


System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed.
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)


System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Controls.DataGridCell.OnCoerceIsReadOnly(DependencyObject d, Object baseValue)
   at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.CoerceValue(DependencyProperty dp)
   at System.Windows.Controls.DataGridCell.PrepareCell(Object item, DataGridRow ownerRow, Int32 index)
   at System.Windows.Controls.Primitives.DataGridCellsPresenter.PrepareContainerForItemOverride(DependencyObject element, Object item)
   at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
   at System.Windows.Controls.DataGridCellsPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled)
   at System.Windows.Controls.DataGridCellsPanel.GenerateChildren(IItemContainerGenerator generator, Int32 startIndex, Int32 endIndex, Size constraint)
   at System.Windows.Controls.DataGridCellsPanel.GenerateAndMeasureChildrenForRealizedColumns(Size constraint)
   at System.Windows.Controls.DataGridCellsPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(IItemContainerGenerator& generator, IContainItemStorage& itemStorageProvider, IContainItemStorage& parentItemStorageProvider, Object& parentItem, Boolean& hasUniformOrAverageContainerSizeBeenSet, Double& computedUniformOrAverageContainerSize, Double& computedUniformOrAverageContainerPixelSize, Boolean& computedAreContainersUniformlySized, Boolean& hasAnyContainerSpanChanged, IList& items, Object& item, IList& children, Int32& childIndex, Boolean& visualOrderChanged, Boolean& isHorizontal, Size& childConstraint, Rect& viewport, VirtualizationCacheLength& cacheSize, VirtualizationCacheLengthUnit& cacheUnit, Int64& scrollGeneration, Boolean& foundFirstItemInViewport, Double& firstItemInViewportOffset, Size& stackPixelSize, Size& stackPixelSizeInViewport, Size& stackPixelSizeInCacheBeforeViewport, Size& stackPixelSizeInCacheAfterViewport, Size& stackLogicalSize, Size& stackLogicalSizeInViewport, Size& stackLogicalSizeInCacheBeforeViewport, Size& stackLogicalSizeInCacheAfterViewport, Boolean& mustDisableVirtualization, Boolean isBeforeFirstItem, Boolean isAfterFirstItem, Boolean isAfterLastItem, Boolean skipActualMeasure, Boolean skipGeneration, Boolean& hasBringIntoViewContainerBeenMeasured, Boolean& hasVirtualizingChildren)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverrideImpl(Size constraint, Nullable`1& lastPageSafeOffset, List`1& previouslyMeasuredOffsets, Nullable`1& lastPagePixelSize, Boolean remeasure)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.Controls.DataGrid.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Page.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

.Net 8
windows 11
Any cpu

### Other information

the page keep frozen after that exception and when reopen the page not showing anything unless restarting the application again 
@harshit7962 harshit7962 added the Investigate Requires further investigation by the WPF team. label Sep 2, 2024
@lindexi
Copy link
Contributor

lindexi commented Sep 11, 2024

I can not repro this issues that I just create the simple DataGrid control.

@alraseensaad Could you upload your project code?

@alraseensaad
Copy link
Author

Delay the loading like loading large data and will loading press the windows button + arrow it will throw the exception

If the datagrid load is fast, nothing will happen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

3 participants