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
45
Bug: xamContextMenu null reference exception in XamMenuItem.RaiseClickEvent()
posted

Hi,

we have NetAdvantage for WPF (v2011.2). I can't use the xamContext menu because a null reference exception is thrown if the menuItem is clicked. 

I tried Service Release 2, and hoped that this bug has been fixed "Element hosted menu throwing NullReferenceException during GetClickedElements method." But it didn't help. Same behavior as before.

 

Here is the stacktrace:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Infragistics.Controls.Menus.XamMenuItem.RaiseClickEvent()
   at Infragistics.Controls.Menus.XamMenuItem.HandleItemSelection()
   at Infragistics.Controls.Menus.XamMenuItem.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonUpThunk(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.OnMouseUpThunk(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.ContentElement.RaiseTrustedEvent(RoutedEventArgs args)
   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, WindowMessage 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, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

 

Our xaml is:

 <DataTemplate x:Key="TreeItemTemplate">
      <StackPanel Orientation="Horizontal" Margin="-3">
        <!--StackPanel.ContextMenu>
          <ContextMenu Visibility="{Binding Path=Data.ContextMenu.Visibility}"
                     ItemsSource="{Binding Path=Data.ContextMenu.MenuItems}"/>
        </StackPanel.ContextMenu-->
        <!-- xamContextMenu bug? null reference exception on Click event! -->
        <ig:ContextMenuService.Manager>
        <ig:ContextMenuManager>
          <ig:ContextMenuManager.ContextMenu>
            <ig:XamContextMenu Visibility="{Binding Path=Data.ContextMenu.Visibility}"
                               ItemsSource="{Binding Path=Data.ContextMenu.MenuItems}"
                               HierarchicalItemTemplate="{StaticResource MenuItemTemplate}"
                               ItemContainerStyleSelector="{StaticResource menuSeparatorStyleSelector}"
                               />
          </ig:ContextMenuManager.ContextMenu>
        </ig:ContextMenuManager>
      </ig:ContextMenuService.Manager>
        <Image Name="groupImg" Width="16" Height="14" Source="{Binding Data.GroupIcon}" VerticalAlignment="Center" />
        <Image Width="16" Height="14" Margin="3" Source="{Binding Data.Icon}" VerticalAlignment="Center" />
        <TextBlock Name="nodeTxt" Text="{Binding Data.Text}" Foreground="{Binding Data.TextColor}" FontWeight="{Binding Data.FontWeight}" VerticalAlignment="Center"/>
      </StackPanel>
    <DataTemplate.Triggers>
      <!-- Only show group icon if not null -->
      <DataTrigger Binding="{Binding Data.GroupIcon}" Value="{x:Null}">
        <Setter TargetName="groupImg" Property="Visibility" Value="Collapsed" />
      </DataTrigger>
    </DataTemplate.Triggers>
  </DataTemplate>

 

Please let me know if you need more input. Thanks in advance.

Parents Reply Children
No Data