Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
2009.1 AutoFit & DataRecordCellAreaGridTemplate
posted

I just upgraded to the new 2009 version of the controls and I found out that some of my old code isn't working anymore: I had a couple of XamDataGrid's in my application and I was using FieldLayoutSettings.DataRecordCellAreaGridTemplate to create a custom gridlayout for the fields. But I'm getting a NullReferenceException whenever I resize a field to the right. Yes this might sound strange but it's true, only when I resize a field to the right the exception is thrown and when I resize it to the left everything works fine....

Here is the code I'm using:

 <igDP:XamDataGrid Name="dataGrid" GroupByAreaLocation="None" Theme="Office2k7Blue" ScrollingMode="Immediate" AutoFit ="True" AllowDrop="True" DragDrop.Drop="dataGrid_Drop" DragDrop.PreviewDragOver="dataGrid_PreviewDragOver" Background="Transparent">
 <igDP:XamDataGrid.FieldLayoutSettings>
  <igDP:FieldLayoutSettings AutoGenerateFields="False" SelectionTypeRecord="Single" AllowAddNew="False" AllowDelete="False">
   <igDP:FieldLayoutSettings.DataRecordCellAreaGridTemplate>
    <ItemsPanelTemplate>
     <Grid>
      <Grid.ColumnDefinitions>
       <ColumnDefinition Width="150*"/>
       <ColumnDefinition Width="100*"/>
       <ColumnDefinition Width="50"/>
      </Grid.ColumnDefinitions>
     </Grid>
    </ItemsPanelTemplate>
   </igDP:FieldLayoutSettings.DataRecordCellAreaGridTemplate>
  </igDP:FieldLayoutSettings>
 </igDP:XamDataGrid.FieldLayoutSettings>
 <igDP:XamDataGrid.FieldLayouts>
  <igDP:FieldLayout>
   <igDP:FieldLayout.Fields>
    <igDP:Field Name="Name" Label="{DynamicResource QuestionText}">
     <igDP:Field.Settings>
      <igDP:FieldSettings AllowEdit="False" AllowGroupBy="False" AllowSummaries="False" CellClickAction="SelectRecord">
       <igDP:FieldSettings.CellValuePresenterStyle>
       <Style TargetType="{x:Type igDP:CellValuePresenter}">
         <Setter Property="ToolTip" Value="{Binding Path=DataItem.Name}"/>
        </Style>
      </igDP:FieldSettings.CellValuePresenterStyle>
      </igDP:FieldSettings>
     </igDP:Field.Settings>
    </igDP:Field>
    <igDP:Field Name="ReportText" Label="{DynamicResource ReportText}">
     <igDP:Field.Settings>
      <igDP:FieldSettings AllowEdit="False" AllowGroupBy="False" AllowSummaries="False" CellClickAction="SelectRecord">
       <igDP:FieldSettings.CellValuePresenterStyle>
        <Style TargetType="{x:Type igDP:CellValuePresenter}">
         <Setter Property="ToolTip" Value="{Binding Path=DataItem.ReportText}"/>
        </Style>
       </igDP:FieldSettings.CellValuePresenterStyle>
      </igDP:FieldSettings>
     </igDP:Field.Settings>
    </igDP:Field>
    <igDP:Field Name="NumberOfTimesAsked" Label="{DynamicResource ColumnNumberOfTimesAsked}">
     <igDP:Field.Settings>
      <igDP:FieldSettings AllowEdit="False" AllowGroupBy="False" AllowSummaries="False" CellClickAction="SelectRecord" /> 
     </igDP:Field.Settings>
    </igDP:Field>
   </igDP:FieldLayout.Fields>
  </igDP:FieldLayout>
 </igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>

 

 

And more info on the Exception:

System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."
  Source="Infragistics3.Wpf.DataPresenter.v9.1"
  StackTrace:
       at Infragistics.Windows.DataPresenter.DataPresenterBase.Infragistics.Windows.Resizing.IResizeHost.Resize(FrameworkElement resizableItem, Boolean resizeInXAxis, Double delta)
       at Infragistics.Windows.Resizing.ResizeController.ResizeToNewMousePosition(MouseDevice mouseDevice)
       at Infragistics.Windows.Resizing.ResizeController.OnPreviewMouseLeftButtonUp(Object sender, MouseButtonEventArgs e)
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       at System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e)
       at System.Windows.UIElement.OnPreviewMouseUpThunk(Object sender, MouseButtonEventArgs e)
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at System.Windows.Interop.HwndSource.InputFilterMessage(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 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at Questionbase.QuestionbaseManager.TestClient.App.Main() in D:\Projects\Effectory Questionbase\Questionbase\Questionbase.TestClient\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Parents Reply Children