Bug with Virtualization and ContextMenu

3 posts, 0 answers
  1. Miky
    Miky avatar
    4 posts
    Member since:
    Mar 2011

    Posted 29 Mar 2011 Link to this post

    Hello,
    I got a RadTreeView with 1000 items and using Virtualization.
    Its definition is:
    <telerik:RadTreeView x:Name="MyTree" ContextMenu="{StaticResource ResourceKey=contextManager}"  IsEditable="true"  Grid.Row="1" ItemsSource="{Binding Path=Devices.Children}"   IsLineEnabled="True" SelectionMode="Extended" ItemTemplateSelector="{StaticResource ItemSelector}" ItemContainerStyleSelector="{StaticResource ItemContainerSelector}" IsVirtualizing="true" IsDragDropEnabled="True" IsDragPreviewEnabled="True" IsDragTooltipEnabled="True" IsDropPreviewLineEnabled="True" PreviewDragEnded="TreeView_DragEnded"/>
    I'm using a style to set all RadTreeViewItem a context menu like that:
    <Style x:Key="DeviceContainerStyle" TargetType="telerik:RadTreeViewItem">
                   <Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay}"/>
                   <Setter Property="IsEditable" Value="False"/>
                   <Setter Property="IsExpanded" Value="{Binding IsExpanded,Mode=TwoWay}"/>
                   <Setter Property="telerik:RadContextMenu.ContextMenu"  Value="{StaticResource ResourceKey=contextDevice}" />
     </Style>
    contextDevice is a really simple context menu. with one RadMenuItem in it.

    The problem: when scrolling to the bottom of the list and right click an item, the context menu opens fine. But when i scroll back to top of the tree, and right click an item, i get the following exception:

    Message: Value cannot be null. Parameter name: format
    Stack Trace:    at System.String.Format(IFormatProvider provider, String format, Object[] args)
       at Telerik.Windows.Controls.SRLoader`1.GetString(String defaultNamespace, String name, Object[] args) in c:\Builds\WPF_Scrum\Current_HotFix\Sources\Development\Core\Controls\SRLoader.cs:line 78
       at Telerik.Windows.Controls.SR.GetString(String name, Object[] args) in c:\Builds\WPF_Scrum\Current_HotFix\Sources\Development\Core\Controls\SR.cs:line 33
       at Telerik.Windows.Controls.RadContextMenu.CreateRootPopup(Popup popup, UIElement child) in c:\Builds\WPF_Scrum\Current_HotFix\Sources\Development\Controls\Navigation\Menu\ContextMenu.cs:line 767
       at Telerik.Windows.Controls.RadContextMenu.HookupRootPopup() in c:\Builds\WPF_Scrum\Current_HotFix\Sources\Development\Controls\Navigation\Menu\ContextMenu.cs:line 1168
       at Telerik.Windows.Controls.RadContextMenu.OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) in c:\Builds\WPF_Scrum\Current_HotFix\Sources\Development\Controls\Navigation\Menu\ContextMenu.cs:line 658
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       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.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Telerik.Windows.Controls.RadContextMenu.set_IsOpen(Boolean value) in c:\Builds\WPF_Scrum\Current_HotFix\Sources\Development\Controls\Navigation\Menu\ContextMenu.cs:line 318
       at Telerik.Windows.Controls.RadContextMenu.TriggerEventFired() in c:\Builds\WPF_Scrum\Current_HotFix\Sources\Development\Controls\Navigation\Menu\ContextMenu.cs:line 899
       at Telerik.Windows.Controls.RadContextMenu.OnEventTriggered(Object sender, EventArgs e) in c:\Builds\WPF_Scrum\Current_HotFix\Sources\Development\Controls\Navigation\Menu\ContextMenu.cs:line 864
       at Telerik.Windows.Controls.RadContextMenu.RoutedEventFired(Object sender, RoutedEventArgs e) in c:\Builds\WPF_Scrum\Current_HotFix\Sources\Development\Controls\Navigation\Menu\ContextMenu.cs:line 1059
       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.UIElement.RaiseTrustedEvent(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, 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)

    Please note that when i set IsVirtualizing=false the problem is solved ! but i get really bad memory consume

    Thanks for your help.
    Miky.
  2. Miky
    Miky avatar
    4 posts
    Member since:
    Mar 2011

    Posted 29 Mar 2011 Link to this post

    I further investigated it, and it seems that the problem only occurs when i have 2 different context menus.
    I'm using the ItemContainerStyleSelector to set a different RadTreeViewItem style, and each style have it's own context menu.
    If i have in the view only type A items, and i right click, the context menu works perfect. But when i scroll to a place where i have both node types and i right click - the above exception is thrown.

    Waiting for your assistance.
    Miky.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 01 Apr 2011 Link to this post

    Hi Miky,

    The code provided is insufficient for us to reproduce the mentioned issue. Could you please examine the "Custom Context Menu" demo of the WPF RadTreeView Demos here. Let us know if it helps you or not.

    Best wishes,
    Petar Mladenov
    the Telerik team
Back to Top