Binding MaxHeight of RadWrapPanel in a style

3 posts, 0 answers
  1. Peter
    Peter avatar
    9 posts
    Member since:
    Jun 2010

    Posted 23 May 2011 Link to this post


    I'm trying to dynamically update the MaxHeight  property of a RadMenuItem based upon the value in another property (binding to a frameworkelement ActualHeight). The binding appears to work great when I first click on each RadMenuItem, upon subsequent clicking of each Item the binding is no longer respected. Binding code below...

    The property getter for DropDownMenuMaxSize is called upon first click of each menu item but never called again. The Setter is called when I expect it to, but in turn the breakpoint on the getter for DropDownMenuMaxSize is never called again. I've tried putting a dummy converter on the style binding, but that is only called once as well.  Any suggestions?
    <Style x:Key="RadMenuItemStyle" TargetType="telerik:RadMenuItem">
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="ItemsPanel">
    <Setter Property="ItemsPanel">
                          <telerik:RadWrapPanel Orientation="Vertical" MaxHeight="{Binding ElementName=xThisWindow, Path=DropDownMenuMaxSize}"/>
        <telerik:ContainerBindingCollection x:Key="RadMenuDataItemBinding">
            <telerik:ContainerBinding PropertyName="IsChecked" Binding="{Binding IsChecked, Mode=TwoWay}" />
            <telerik:ContainerBinding PropertyName="IsEnabled" Binding="{Binding IsEnabled, Mode=TwoWay}" />
            <telerik:ContainerBinding PropertyName="IsCheckable" Binding="{Binding IsCheckable}" />
            <telerik:ContainerBinding PropertyName="IsSeparator" Binding="{Binding IsSeparator}" />
            <telerik:ContainerBinding PropertyName="StaysOpenOnClick" Binding="{Binding StaysOpenOnClick}" />

    <telerik:RadMenu x:Name="xRadMenuTools" Width="Auto" Margin="4,3,0,3" Height="22" ClickToOpen="True" ItemClick="RadMenu_ItemClick" HorizontalAlignment="Left" ItemContainerStyle="{StaticResource RadMenuItemStyle}">
                    <telerik:RadMenuItem x:Name="xRadMenuItem1" Header="Tools">
                                <telerik:HierarchicalDataTemplate telerik:ContainerBinding.ContainerBindings="{StaticResource RadMenuDataItemBinding}">
                                    <TextBlock Text="{Binding DisplayName}" controlsToolTip:ToolTipService.ToolTip="{Binding ToolTip}"/>
    ..more menu items....
  2. Valeri Hristov
    Valeri Hristov avatar
    2252 posts

    Posted 26 May 2011 Link to this post

    Hello Peter,

    Can you send us a simple project that can be used to observe the problem? I am pretty sure your requirement is not possible in Silverlight (you cannot bind to ActualWidth/ActualHeight in Silverlight) but I would like to try to help.

    Best wishes,
    Valeri Hristov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Peter
    Peter avatar
    9 posts
    Member since:
    Jun 2010

    Posted 06 Jun 2011 Link to this post


    I modified the binding to a separate property (not ActualHeight) and still had the same behavior. The getter for the property simply isn't called when the property changes after the first time click, unless the RadMenuItem collection is changed. A temporary workaround I found is to empty out the ItemSource collection of bound RadMenuItems and add them back in, then when the RadMenu is clicked the getter is called and all works as expected. If I get a chance I will put together a sample project as suggested. Thank you.
Back to Top