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
2370
XamRibbon -- MenuTool.ItemTemplate not entirely selectable
posted

Hello,

I want the entire area of the DataTemplate to be selectable/clickable.  I am putting ButtonTool items in the ItemTemplate and I have to click directly on the label to initiate the click.  There is some area on the left (probably for an image on each item or something) and some on top/bottom/right of the text where the click closes the MenuTool, but the Command/Event is not fired.  I have attached a sample showing this behavior. Just run the project and click Add in the ribbon.  What I really want is for the whole "yellow" area on the default theme that shows up on hover to be selectable/clickable.  My real project uses the Office2013 theme, so if you need to override a theme or something to get this to work, keep that in mind.  

Thanks!

Jon

TestMenuTool.zip
Parents
  • 1935
    posted

    Hello Jon Heaton,

    Thank you for providing a sample.

    The reason why you need to click only over the label to fire the click event, is because the ItemTemplate is similar to the HeaderTemplate in the ToolMenuItem and it should only affect the section on the right where the text/header is.

    I have taken a look at your scenario and what you could do is to define a style for ToolMenuItem and handle the PreviewMouseLeftButtonDown event. Please note that this style should be based on the RibbonOffice2013.ToolMenuItem in order the clicking of the tool menu item to work properly when Office2013 theme is set. In addition, the style should be moved into the XamRibbon's Resources.

    The following snippet code illustrates the style's definition:

    <ribbon:XamRibbon Theme="Office2013">

    <ribbon:XamRibbon.Resources>

    <Style TargetType="{x:Type ribbon:ToolMenuItem}" BasedOn="{x:Static igThemes:RibbonOffice2013.ToolMenuItem}">

    <Setter Property="FontSize" Value="14" />

    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="item_PreviewMouseLeftButtonDown" />

    </Style>

    </ribbon:XamRibbon.Resources>

      
    ---

    Now there is no need to use a ItemTemplate and add a button.

    Please take a look at the attached sample and let me know if that works for you or if you have any other questions on this matter.

    TestMenuTool_Modified.zip
Reply Children