2011-01-31 2 views
0

이 점이 나를 괴롭 히고 있습니다. 이 문제는 데이터 막대가 스크롤 막대가 필요하기에 충분할 때만 나타납니다. 따라서 데이터 가상화가이 문제를 해결할 것을 강력하게 제안합니다. 아래 xaml에서 볼 수 있듯이이 데이터 격자에 대해 마지막으로 정의 된 열은 가시성이 컨트롤의 데이터 소스 인 DataGridCollectionView의 부울 "ErrorsPresent"속성에 바인딩 된 버튼입니다. 큰 데이터 집합이 컨트롤에로드 될 때 알 수없는 이유로 인해 모든 속성에 null 값이있는 빈 행이 있습니다. 마지막 열을 주석으로 처리하면 표와 데이터가 제대로 표시되지만 변환기의 행 데이터가 실제로 처리 될 때 PresentationFramework에서이 불쾌한 오류가 발생합니다. 모든 것을 포함 시켜서 유감이지만 모든 Windows 코드가 다음과 같음을 보여주고 싶습니다.Xceed Datagrid에서 단추에 속성을 바인딩 할 때 NullReferenceException이 발생합니다.

'APreII.vshost.exe'(Managed (v4.0.30319)) : 'C : \ Windows \ Microsoft.Net \ assembly \ GAC_MSIL \ Accessibility \ v4.0_4.0.0.0__b03f5f7f11d50a3a \ Accessibility.dll ' System.Transactions 중요 : 0 : http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledUnhandled 예외 APreII.vshost.exeSystem.NullReferenceException, mscorlib, 버전 = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089 개체 참조가 개체의 인스턴스로 설정되지 않았습니다. System.Windows.Data.BindingExpression.TransferValue (Object newValue, Boolean isASubPropertyChange)에서 System.Windows.Data.BindingExpression.Activate (Object 항목) at System.Windows.Data.BindingExpression.AttachToContext (AttachAttempt 시도) 시스템에서 .Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext (Boolean lastChance) MS.Internal.Data.DataBindEngine.Task.Run (Boolean lastChance) at MS.Internal.Data.DataBindEngine.Run (Object ARG) System.Windows.ContextLayoutManager에서 System.Windows.ContextLayoutManager.UpdateLayout에서 System.Windows.ContextLayoutManager.fireLayoutUpdateEvent에서 MS.Internal.Data.DataBindEngine.OnLayoutUpdated (개체 보낸 사람, EventArgs입니다 전자) () () 에서. 유 pdateLayoutCallback System.Windows.Media.MediaContext.RenderMessageHandler (resizedCompositionTarget 객체) 에서 System.Windows.Media.MediaContext.RenderMessageHandlerCore (resizedCompositionTarget 객체) 에서 System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 에서 (개체 ARG) 에서 System.Windows.Threading.ExceptionWrapper.InternalRealCall (대리자 콜백, 개체 인수, Int32 numArgs) MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen (개체 소스, 대리 메서드, 개체 인수, Int32 numArgs, Delegate catchHandler) at System. Windows.Threading.Dispatcher.WrappedInvoke (Delegate 콜백, Object args, Int32 numArgs, Delegate catchHandler)at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Threading.Exe System.Threading.ExecutionContext.Run에서 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup (TryCode 코드 CleanupCode backoutCode, userData에 개체)에서 cutionContext.runTryCode (userData에 개체) (ExecutionContext에 ExecutionContext에, ContextCallback 콜백, 상태 객체 부울 ignoreSyncCtx) System.Windows.Threading.Dispatcher.ProcessQueue()에서 System.Windows.Threading.DispatcherOperation.Invoke()에서 System.Threading.ExecutionContext.Run (ExecutionContext에 ExecutionContext에, ContextCallback 콜백, 객체 상태)에서 System.Windows에서 .Threading.Dispatcher.WndProcHook (IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean & amp; System.Windows.Threading에서 MS.Win32.HwndSubclass.DispatcherCallbackOperation (객체 O)에서 처리 ) ; MS.Win32.HwndWrapper.WndProc (HWND를 IntPtr, INT32의 MSG,을 IntPtr의 wParam,을 IntPtr의 lParam 부울 & A에서) 처리 .ExceptionWrapper.InternalRealCall (대리자 콜백, 개체 인수, Int32 numArgs) MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen (개체 소스, 대리 메서드, 개체 인수, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.WrappedInvoke Delegate catchHandler) 에서 System.Windows.Threading.Dispatcher.InvokeImpl (DispatcherPriority 우선 순위, TimeSpan 시간 제한, 대리 메서드, Object 인수, Int32 numArgs) 에서 MS.Win32.HwndSubclass.SubclassWndProc (IntPtr HWND, INT32의 MSG, MS.Win32.UnsafeNativeMethods.DispatchMessage을 IntPtr에서의 wParam,을 IntPtr의 lParam) (MSG & A; System.Windows.Application에서 System.Windows.Threading.Dispatcher.PushFrameImpl에서 MSG) (DispatcherFrame 프레임) . RunInter \ tfs \ Hermes \ dev \ Hermes5.0 \ src \ UIServices \ APreII \ obj \ Debug \ App의 APreII.App.Main()에있는 System.Windows.Application.Run() 의 .g.cs : System.AppDomain._nExecuteAssembly의 라인 0 (RuntimeAssembly 조립체 문자열 [] 인수) System.Runtime.Hosting.ApplicationActivator.CreateInstance에서 (activationContext activationContext 문자열 [] activationCustomData)에서 Microsoft.VisualStudio.HostingProcess 시스템에서 .HostProc.RunUsersAssemblyDebugInZone() System.Threading.ExecutionContext.Run (ExecutionContext에 ExecutionContext에, ContextCallback 콜백, 객체 상태 부울 ignoreSyncCtx) System.Threading.ExecutionContext.Run에서 에서 (ExecutionContext에 ExecutionContext에, ContextCallback 콜백 상태 객체) .Threading.ThreadHelper.ThreadStart () System.NullReferenceException : 개체 참조가 개체의 인스턴스로 설정되지 않았습니다. System.Windows.Data.BindingExpression.AttachToContext에서 System.Windows.Data.BindingExpression.Activate (개체 항목) 에서 System.Windows.Data.BindingExpression.TransferValue (NEWVALUE, 부울 isASubPropertyChange 개체) (AttachAttempt 시도) 에서 에서 System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext (Boolean lastChance) MS.Internal.Data.DataBindEngine.Task.Run (Boolean lastChance) (에서 MS.Internal.Data.DataBindEngine.Run 등산용에서 System.Windows.ContextLayoutManager.UpdateLayout() 에서 System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() 에서 MS.Internal.Data.DataBindEngine.OnLayoutUpdated (개체 보낸 사람, EventArgs입니다 전자) 에서 개체 ARG) m.Windows.ContextLayoutManager.UpdateLayoutCallback System.Windows.Media.MediaContext.RenderMessageHandler에서 System.Windows.Media.MediaContext.RenderMessageHandlerCore (resizedCompositionTarget 객체) 에서 System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 에서 (개체 ARG) (Object resizeCompositionTarget) at System.Windows.Threading.ExceptionWrapper.InternalRealCall (대리자 콜백, 대리자 인수, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen (개체 소스, 대리 메서드, 개체 args, Int32 numArgs, 대리자 catchHandler) at System.Windows.Threading.Dispatcher.WrappedInvoke (대리자 콜백, 개체 args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl()System.Threading.ExecutionContext.Run (ExecutionContext에의 ExecutionContext에서 91,363,210 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup에서 System.Threading.ExecutionContext.runTryCode (객체 userData에) 에서 (TryCode 코드, CleanupCode backoutCode, userData에 객체) , ContextCallback 콜백, System.Windows.Threading.Dispatcher.ProcessQueue에서 System.Windows.Threading.DispatcherOperation.Invoke() 에서 System.Threading.ExecutionContext.Run (의 ExecutionContext의 ExecutionContext, ContextCallback 콜백 개체 상태) 에서 개체 상태, 부울 ignoreSyncCtx) () at System.Windows.Threading.Dispatcher.MS.Win32.HwndWrapper.WndProc에서 ; WndProcHook (처리를 IntPtr HWND, INT32의 MSG,을 IntPtr의 wParam,을 IntPtr의 lParam 부울 & A) (을 IntPtr HWND, INT32의 MSG,을 IntPtr의 wParam,을 IntPtr의 lParam 부울 & A; 처리)에 MS.Win32.HwndSubclass.DispatcherCallbackOperation (Object o)에서 System.Windows.Threading.ExceptionWrapper.InternalRealCall (위임 콜백, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen (개체 소스, 대리 메서드, System.Windows.Threading.Dispatcher.WrappedInvoke (대리자 콜백, 개체 args, Int32 numArgs, Delegate catchHandler) 에서 (DispatcherPriority 우선 순위, TimeSpan 시간 제한 , 나를 위임해라. int32 numArgs) 에서 MS.Win32.HwndSubclass.SubclassWndProc (IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage (MSG & amp; APreII.App.Main에서 System.Windows.Application.Run()에서 System.Windows.Application.RunInternal (윈도우 윈도우)에서 System.Windows.Threading.Dispatcher.PushFrameImpl (DispatcherFrame 프레임) 에서 MSG) () D : \ tfs \ Hermes \ dev \ Hermes5.0 \ src \ UIServices \ APreII \ obj \ Debug \ App.g.cs : 줄 0 at System.AppDomain._nExecuteAssembly (RuntimeAssembly assembly, String [] args) at System.Runtime.Hosting.ApplicationActivator.CreateInstance (ActivationContext executionContext, String [] activationCustomData)에서 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() at System.Threading.ExecutionContext.Run (ExecutionContext 실행 컨텍스트, ContextCallback 콜백, 개체 상태, 부울 ignoreSyncCtx) 시스템에서 . Thread.ExecutionContext.Run (ExecutionContext executionContext, ContextCallback 콜백, 개체 상태)at System.Threading.ThreadHelper.ThreadStart()

Xaml. CanContentScroll & ItemScrollingBehavior 속성을 설정하여 가상화를 사용하지 않도록 설정 한 경우 으로 변경되었습니다. : 어떤 도움

 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); 
    } 

감사 :

   <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을 만들고있어 얼마나 웃음에 대한

. 데이터 가상화 (문제가있는 경우)를 올바르게 해제하는 방법, 기본 데이터 집합 및 DataGridCollectionView에없는 null 레코드를 CellContentTemplate Visibility 변환기에서 처리하는 방법을 모르겠습니다.

답변

0

나는 내 자신의 질문에 답하기를 싫지만 1 일 후 여기에 우리가 있습니다. 한숨. XAML에서 내 변환기 호출에 대해 Xceed 문서에서 가져온 조상 datarow를 가져 왔지만 변환기에 대해 (단지 '바인딩') 신경 쓰이는 속성 만 보내면 작동하는 것 같습니다. 내 생각 엔 원래의 오류는 다른 스레드에서 가상화로 수행되는 일부 작업으로 인해 발생했기 때문에 내 코드를 가리키는 스택 추적이 부족합니다.

이 작동 :

     <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>