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
20
Menu popup closes unexpectadly when clicking a contained control
posted

Hello,
I've stumbled across a problem with the popup of the XamRibbon MenuTool, and although I'm not sure if it's IG specific or general for WPF, I would appriciate your assistance.

I have an MVVM application which uses the XamRibbon's different tools outside of an actual XamRibbon. In order to present any UserControl (or ViewModel) inside the menu popup, I've created a template for ToolMenuItem, based on the default IG style (see template below).

The template works fine presenting any content I give it, but if this content contains any control, and that control is pressed, the popup suddenly disappears. So far this phenomenon applies to all controls except for Slider, which for some reason doesn't close the popup,

listed below is the forementioned template and a short example of using it:

<ControlTemplate x:Key="{x:Static igRibbon:MenuToolBase.SubmenuItemTemplateKey}" TargetType="{x:Type igRibbon:ToolMenuItem}">

<Grid>

<Border x:Name="Bd" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="true">

<Border.Background>

<SolidColorBrush x:Name="highlight" Color="{DynamicResource MainWashColor}" Opacity="0.6"/>

</Border.Background>

<Grid>

<Grid,ColumnDefinitions>

<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup"/>

</Grid,ColumnDefinitions>

<!-- Content -->

<Grid x:Name="ContentArea" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,1,0">

<Grid.RowDefinitions>

<RowDefinition Height="Auto"/>

</Grid.RowDefinitions>

<ContentPresenter x:Name="Content" ContentSource="Header" HorizontalAlignment="Stretch" VerticalAlignment="Center" RecognizesAccessKey="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

</Grid>

</Grid>

</Border

</Grid>

<ControlTemplate.Triggers>

 <Trigger Property="IsEnabled" Value="false">

<Setter Property="Foreground" Value="{DynamicResource {x:Static igRibbon:RibbonBrushKeys.ToolDisabledForegroundTextFillKey}}"/>

</Trigger>

<Trigger Property="IsHighlighted" Value="true">

<Setter Property="Foreground" Value="{DynamicResource {x:Static igRibbon:RibbonBrushKeys.TextHottrackFillKey}}"/>

<Setter TargetName="highlight" Property="Opacity" Value="0.5"/>

</Trigger>

</ControlTemplate.Triggers>

</ControlTemplate>

-----------------------------------------------------------------------

<igRibbon:MenuTool ButtonType="Segmented" Caption="MenuTool1" igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge" Command="{Binding SwitchStateCommand}" LargeImage="{Binding IconPath}"

<Grid>

<Grid.RowDefinitions>

<RowDefinition Height="Auto"/>

<RowDefinition/><RowDefinition/><RowDefinition/>

</Grid.RowDefinitions>

<Slider Grid.Row="0" Orientation="Horizontal"/>

<Button Grid.Row="1" Content="Button1" Command="{Binding ButtonOneCommand}"/>

<Button Grid.Row="2" Content="Button2" Command="{Binding ButtonTwoCommand}"/>

<Expander Grid.Row="3"/>

</Grid>

</igRibbon:MenuTool>

 

Please let me know if there is anything missing in order to find the problem.

Your quick response will be much appriciated...

Thanks, Florance.

 

  • 138253
    Offline posted

    Hello Florance,

     

    Thank you for your post. I have been looking through it and the code you have provided and I suggest you add the following code in your Buttons’ PreviewMouseLeftbuttonDown events:

     

    e.Handled = true;

     

    Also I can say that the XamRibbon Tools are not meant to be used standalone and it is normal not behave as expected when they are not in the XamRibbon. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.