0

これは私を狂わせています。この問題は、データグリッドがスクロールバーを必要とするほど大きい場合にのみ発生するため、データの仮想化がこれに役立つことを強くお勧めします。下のxamlからわかるように、このデータグリッドに定義された最後の列は、コントロールのデータソースであるDataGridCollectionViewのブール値の「ErrorsPresent」プロパティに可視性がバインドされているボタンです。なんらかの理由で、私にはわかりませんが、大きなデータセットがコントロールに読み込まれると、すべてのプロパティにnull値を持つ空の行がいくつかあります。最後の列をコメントアウトすると、グリッドとそのデータは正しく表示されますが、行のデータが実際に処理されると(コンバーターのように)、PresentationFrameworkでこの厄介なエラーが発生します。すべてを含めて申し訳ありませんが、すべてのWindowsコードを示したいと思います。

'APreII.vshost.exe'(管理対象(v4.0.30319)):ロード済み'C:\ Windows \ Microsoft.Net \ assembly \ GAC_MSIL \ Accessibility \ v4.0_4.0.0.0__b03f5f7f11d50a3a \ Accessibility.dll' System.Transactions Critical: 0:http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledUnhandled exceptionAPreII.vshost.exeSystem.NullReferenceException、mscorlib、Version = 4.0.0.0、Culture = neutral、PublicKeyToken = b77a5c561934e089Objectオブジェクトのインスタンスに設定されていない参照。System.Windows.Data.BindingExpression.TransferValue(Object newValue、Boolean isASubPropertyChange)at System.Windows.Data.BindingExpression.Activate(Object item)at System.Windows.Data.BindingExpression.AttachToContext(AttachAttemptattempt)atSystem.Windows。 Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient。System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext、ContextCallbackコールバック、オブジェクト状態)のContextCallbackコールバック、オブジェクト状態、ブール値ignoreSyncCtx)System.Threading.ThreadHelper.ThreadStart()System.NullReferenceException:オブジェクト参照がインスタンスのインスタンスに設定されていません物体。System.Windows.Data.BindingExpression.TransferValue(Object newValue、Boolean isASubPropertyChange)at System.Windows.Data.BindingExpression.Activate(Object item)at System.Windows.Data.BindingExpression.AttachToContext(AttachAttemptattempt)atSystem.Windows。 Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)at MS.Internal.Data.DataBindEngine.Run(Object arg)atMS。 Internal.Data.DataBindEngine。

Xaml。ご覧のとおり、CanContentScrollプロパティとItemScrollingBehaviorプロパティを設定して仮想化を無効にしようとしましたが、効果はありません。:

                <XceedDG:DataGridControl Grid.Column="2" x:Name="EncounterDataGrid" ItemsSource="{Binding Path = EncounterDataGridCollectionView, UpdateSourceTrigger=PropertyChanged}" 
                                     Background="{x:Static Views:DataGridControlBackgroundBrushes.ElementalBlue}" CellErrorStyle="{StaticResource cell_error}" 
                                     FontSize="12" AutoCreateColumns="False" ItemScrollingBehavior="Immediate" ScrollViewer.CanContentScroll="False"
                                     EditTriggers="None" NavigationBehavior="RowOnly" CellEditorDisplayConditions="None" >

                <XceedDG:DataGridControl.View>
                    <Views:TableView ColumnStretchMode="All" ShowRowSelectorPane="False" ScrollViewer.CanContentScroll="False" 
                     ColumnStretchMinWidth="100"/>
                </XceedDG:DataGridControl.View>
                <!--Group Header formatting-->
                <XceedDG:DataGridControl.Resources>
                    <DataTemplate DataType="{x:Type XceedDG:Group}">
                        <TextBlock Foreground="DarkSlateBlue"
                        Padding="3,3,3,3" VerticalAlignment="Center"
                        FontSize="14" FontWeight="Black" MaxWidth="850" TextWrapping="Wrap"
                        Text="{Binding Path=., Converter={StaticResource GroupHeaderTextConverterType}}"/>
                    </DataTemplate>
                </XceedDG:DataGridControl.Resources>
                <!--Visible column definitions-->
                <XceedDG:DataGridControl.Columns>
                    <XceedDG:Column MinWidth="50"
                     FieldName="AccountNumber" 
                     Title="Account #"
                     IsMainColumn="True" 
                     ShowInColumnChooser="False"
                     TextWrapping="Wrap" 
                     ReadOnly="True" 
                     Visible="True"/>
                    <XceedDG:Column MinWidth="50"
                     FieldName="DOB" 
                     Title="Date of Birth"  
                     IsMainColumn="False"
                     ShowInColumnChooser="False" 
                     TextWrapping="Wrap"
                     ReadOnly="True"  
                     Visible="True"/>

                    <XceedDG:Column MinWidth="4"
                     FieldName="Processed"
                     Title="Processed"
                     IsMainColumn="False" 
                     ShowInColumnChooser="False" 
                     TextWrapping="Wrap"
                     ReadOnly="True" 
                     Visible="True"/>
                   <XceedDG:Column MinWidth="25" 
                     FieldName="ErrorsPresent"
                     Title="Errors"
                     IsMainColumn="False" 
                     ShowInColumnChooser="False" 
                     TextWrapping="Wrap"
                     ReadOnly="True" 
                     Visible="True" >
                    <XceedDG:Column.CellContentTemplate>
                        <DataTemplate>
                            <Button Command="{StaticResource ShowErrorDialogCommand}" CommandParameter="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType={x:Type XceedDG:DataRow}}}" Foreground="Red"
                            Content="View Errors" FontSize="11"
                            Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type XceedDG:DataRow}}, Converter={StaticResource VisibilityConverterBooleanDataRow}, ConverterParameter=ErrorsPresent}"/>
                        </DataTemplate>
                    </XceedDG:Column.CellContentTemplate>

                    </XceedDG:Column>

                </XceedDG:DataGridControl.Columns>
            </XceedDG:DataGridControl>

そして、笑いのためだけに、DataGridCollectionViewをどのように作成しているか:

        private void CreateDataGridCollectionView()
    {
        EncounterDataGridCollectionView = new DataGridCollectionView(Encounters);
        EncounterDataGridCollectionView.Filter = new Predicate<object>(IsIncludedPt);
        //Group by unit
        PropertyGroupDescription groupDescription = new PropertyGroupDescription("UnitID");
        EncounterDataGridCollectionView.GroupDescriptions.Add(groupDescription);
    }

助けてくれてありがとう。データの仮想化を適切にオフにする方法(それが問題である場合)、これらのnullレコード(基になるデータセットとDataGridCollectionViewにない)がCellContentTemplateVisibilityコンバーターによって処理されないようにする方法がわかりません。

4

1 に答える 1

0

1日後に自分の質問に答えるのは嫌いですが、ここにいます。はぁ。コンバーター呼び出しのXAMLでは、いくつかのXceedドキュメントから取得した祖先データ行を取得していましたが、関心のあるプロパティ(「バインド」のみ)のみをコンバーターに送信することは機能しているようです。私の推測では、元のエラーは別のスレッドで仮想化を使用して行われた作業の結果であり、したがって、私のコードのいずれかを指すスタックトレースがありません。

これは動作します:

                        <XceedDG:Column MinWidth="25" 
                     FieldName="ErrorsPresent"
                     Title="Errors"
                     IsMainColumn="False" 
                     ShowInColumnChooser="False" 
                     TextWrapping="Wrap"
                     ReadOnly="True" 
                     Visible="True" >
                    <XceedDG:Column.CellContentTemplate>
                        <DataTemplate>
                            <Button Command="{StaticResource ShowErrorDialogCommand}" CommandParameter="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType={x:Type XceedDG:DataRow}}}" Foreground="Red"
                                    Content="View Errors" FontSize="11"
                                    Visibility="{Binding Converter={StaticResource VisibilityConverterBooleanDataRow}}" />
                            </DataTemplate>
                    </XceedDG:Column.CellContentTemplate>
于 2011-02-01T17:24:37.680 に答える