Hello,
Recently we noticed that
our product was not up for garbage collection when a user logged out,
instead the entire product instance was held in memory. We've isolated it to
what seems to be the RadMenu. Specifically the RadMenuItem when used as a SubMenuItem.
This appears to happen either with RadMenuItems built in XAML, code behind, or
binding to a collection with a template.
I have sample project to reproduce the issue but I couldn't attach it here. This occurs with the newest version 2016.1.112 and previous 2015.3.1104, I’m not sure of other releases.
Attached is a PDF of the Instance Retention Graph from a popular memory profiler.
We have used RadMenus extensively throughout the product and were able to mitigate the issue with manual recursive cleanup by traversing the visual tree to decouple the RadMenuItems, by clearing all RadMenuItems of subitems and then all RadMenu's of all RadMenuItems. This has allowed the vast majority of the product to be collected with the exception of the RadMenuItems items themselves, which appear to be held onto by a ResourceDictionary.
We haven’t noticed this type of behavior with any other control, either Telerik or ours. Is this supposed to be doing this or are we supposed to do something else to release the memory?
If you need any additional info, please don’t hesitate to ask. Thank you,
Patrick
Hi,
I had dynamically set DropDownHeight of RadMenuItem, till now it was working. After that I set the template style for telerikNav:RadMenuItem . But now DropDownHeight functionality has stopped working . Attached(style.txt) is the style code for telerikNav:RadMenuItem. Further attached is the top and bottom arrow of menu that are not showing now due to the template implementation.
view.xaml
<radNav:RadMenu x:Name="mnuMain"
Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
Height="27"
Style="{StaticResource MainTopMenu}" />
<Rectangle x:Name="rctMenuSeparator"
Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2"
Height="2"
Style="{StaticResource MainTopMenuSeparator}" />
///view.xaml.cs code for setting dropdown
if (menuItem.ParentID == 0 && menuItem.MenuItemType == MenuItemType.ParentNode)
{
int subMenuChildCount = menuItems.Count(a => a.ParentID == menuItem.MenuItemID);
if (subMenuChildCount > 15)
menuControl.DropDownHeight = 405;
}
// Style.xaml
<Style x:Key="MainTopMenu" TargetType="telerikNav:RadMenu">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="ClickToOpen" Value="False" />
<Setter Property="Background" Value="{StaticResource MainMenuBackground}" />
<Setter Property="Foreground" Value="#FFFFFF" />
<Setter Property="BorderBrush" Value="{StaticResource MainMenuBackground}" />
</Style>
<Style x:Key="MainTopMenuSeparator" TargetType="Rectangle">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Fill" Value="#FFC2CFE2" />
</Style>
<Style x:Key="RadMenuItemStyle" TargetType="telerikNav:RadMenuItem">
<Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource TopLevelHeaderTemplate}" />
</Style>
<Style TargetType="telerikNav:RadMenuItem" BasedOn="{StaticResource RadMenuItemStyle}" />
<ControlTemplate TargetType="telerikNav:RadMenuItem" x:Key="SeparatorTemplate">
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" HorizontalAlignment="Left" Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Menu.IconColumnWidth}" />
<Grid Grid.Column="1" Height="2" Margin="{StaticResource MenuItemSeparatorMargin}">
<Rectangle Height="1" VerticalAlignment="Top" Fill="{StaticResource MenuItemSeparatorTop}" />
<Rectangle Height="1" VerticalAlignment="Bottom" Fill="{StaticResource MenuItemSeparatorBottom}" />
</Grid>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="TopLevelHeaderTemplate" TargetType="telerikNav:RadMenuItem">
<Grid x:Name="RootElement" Margin="{StaticResource MenuTopLevelItemMargin}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Highlighted">
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="#FF009FE3"/>
</ObjectAnimationUsingKeyFrames>
<ColorAnimation From="Black" To="Black" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(Brush.Color)"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
<Grid x:Name="ContentGrid" Background="Transparent" Margin="{TemplateBinding Padding}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Path x:Name="Tick" Margin="0 0 4 0" Grid.Column="0" Visibility="Collapsed" FlowDirection="LeftToRight" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z" />
<ContentPresenter x:Name="Icon" Margin="0 0 4 0" Grid.Column="0" Content="{TemplateBinding Icon}" ContentTemplate="{TemplateBinding IconTemplate}" />
<TextBlock x:Name="Content" Grid.Column="1" Text="{TemplateBinding Header}"/>
</Grid>
<Popup x:Name="PART_Popup" HorizontalOffset="-1" VerticalOffset="1">
<Grid >
<Grid x:Name="PopupContentElement" Margin="0 0 3 3">
<telerikChromes:ShadowChrome />
<Border BorderThickness="1" BorderBrush="{StaticResource MenuPopupOuterBorder}" Background="{StaticResource MenuPopupBackground}">
<Grid>
<Grid Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Menu.IconColumnWidth}" HorizontalAlignment="Left">
<Rectangle Fill="{StaticResource MenuPopupIconsBackground}" Margin="0 0 2 0" />
<Grid HorizontalAlignment="Right" Margin="{StaticResource MenuPopupIconsSeparatorMargin}">
<Rectangle Width="1" HorizontalAlignment="Right" Margin="0 0 1 0" Fill="{StaticResource MenuPopupIconsSeparatorLeft}" />
<Rectangle Width="1" HorizontalAlignment="Right" Margin="0 0 0 0" Fill="{StaticResource MenuPopupIconsSeparatorRight}" />
</Grid>
</Grid>
<ScrollViewer MaxHeight="300" BorderThickness="0" Padding="0" VerticalScrollBarVisibility="Hidden">
<ItemsPresenter Margin="1"/>
</ScrollViewer>
</Grid>
</Border>
</Grid>
</Grid>
</Popup>
</Grid>
</ControlTemplate>
Regards,
Anmol
<
navigation:Page.Resources
>
<
Styles:MenuItemStyleSelector
x:Key
=
"MenuItemStyleSelector"
TopLevel
=
"{StaticResource MenuItemTopLevelStyle}"
Title
=
"{StaticResource MenuItemTitleStyle}"
Link
=
"{StaticResource MenuItemLinkStyle}"
ParagraphImage
=
"{StaticResource ParagraphImageMenuItemStyle}"
TopLevelSection
=
"{StaticResource MenuItemTopLevelSectionStyle}"
/>
<
telerik:HierarchicalDataTemplate
x:Key
=
"MenuItemTemplate"
ItemsSource
=
"{Binding }"
>
<
telerik:ContainerBinding.ContainerBindings
>
<
telerik:ContainerBindingCollection
>
<
telerik:ContainerBinding
PropertyName
=
"Header"
Binding
=
"{Binding Content}"
/>
<
telerik:ContainerBinding
PropertyName
=
"IsSeparator"
Binding
=
"{Binding IsSeparator}"
/>
</
telerik:ContainerBindingCollection
>
</
telerik:ContainerBinding.ContainerBindings
>
<
HyperlinkButton
Content
=
"{Binding Path=Content}"
NavigateUri
=
"{Binding Path=Url}"
/>
</
telerik:HierarchicalDataTemplate
>
</
navigation:Page.Resources
>
<
StackPanel
>
<
telerik:RadMenu
Style
=
"{StaticResource MenuStyle}"
ItemsSource
=
"{Binding MenuItems}"
ItemTemplate
=
"{StaticResource MenuItemTemplate}"
ItemContainerStyleSelector
=
"{StaticResource MenuItemStyleSelector}"
/>
</
StackPanel
>
Hello,
We have a richtextbox control and a context menu builder. When
1. Add a table in the middle /or on bottom/ of the screen
view
2. Right mouse click in some table’s
cell
and the result is that the Font configuration tends to overlay the context menu
My question is how to make some kind of positioning that avoids overlapping
Thanks!
<
telerik:RadMenu
Grid.Row
=
"2"
Grid.Column
=
"1"
Margin
=
"-6,0,0,0"
VerticalAlignment
=
"Center"
Background
=
"Transparent"
ClickToOpen
=
"True"
IconColumnWidth
=
"0"
>
<
telerik:RadMenuItem
x:Name
=
"KontextRadMenuItem"
StaysOpenOnClick
=
"True"
>
<
telerik:RadMenuItem.Header
>
<
TextBlock
Foreground
=
"DarkBlue"
Text
=
"{Binding SelectedKontextText}"
/>
</
telerik:RadMenuItem.Header
>
<
telerik:RadMenuGroupItem
IsCheckable
=
"True"
ItemTemplate
=
"{StaticResource MenuTemplate}"
ItemsSource
=
"{Binding KontextAuswahlList}"
ScrollViewer.VerticalScrollBarVisibility
=
"Auto"
MaxHeight
=
"300"
Padding
=
"-5,-5,-5,-5"
StaysOpenOnClick
=
"True"
cal:Message.Attach
=
"[Event Checked] = [Action KontextHinzufuegen($source,$eventArgs)]; [Event Unchecked] = [Action KontextEntfernen($source,$eventArgs)];[Event KeyDown] = [Action KontextAuswahlKeyDown($source,$eventArgs)]"
/>
</
telerik:RadMenuItem
>
</
telerik:RadMenu
>