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
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.
Hello Jon,
As a second option, what you could do is bind the Command property in the Style setter of the ToolMenuItem to the property on a view model that has the command.
The following forum thread contains a sample application that is demonstrating this behavior:
http://ko.infragistics.com/community/forums/t/69611.aspx
Please let me know if you have any issues or questions on this matter.
Your solution worked very well. Thank you for your help.
Thanks Martin for your fast response. I am actually updating my DLLs to view your solution at the moment. I will let you know if things are as expected. Thank you!