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
695
XamRibbonGroup ItemSource and ItemTemplate
posted

Hi and thanks for any help in advance.

I am using the XamRibbon and want to use the binding provided by the ItemSource and ItemTemplate of the RibbonGroup object.

I think I have it part working.

My application has multiple modules and each module loads Tabs -> RibbonGroups and Tools.

This all happens in code.  My DataTemplate lives in a ResouceDictionary in a common assembly. 

So in code the critical lines are;

ribbonGroup.ItemsSource = queryBinding; // this returns a simple list
ribbonGroup.ItemTemplate = (DataTemplate)resourceDictionary["RibbonTools"];

 My simple DataTemplate looks like this;

 

 

<

DataTemplate x:Key="RibbonTools">
<igRibbon:ButtonTool Caption="{Binding Caption}" />
</DataTemplate>

What happens is that the RibbonGroup now has what seems to be a few buttons, but they are not styled correctly and seem to be labels or pieces of string, rather than be functional.

Any help or an example on how to do this binding right would be greatly appreciated.

Thanks

 

Parents
  • 54937
    Verified Answer
    Offline posted

    I'm not sure why the buttons seem like labels in your case - if you post a sample I can look at that. That being said, I would not recommend taking this approach for a couple of reasons. First, these tools will be transient - they're only hydrated by the itemscontainergenerator of the itemscontrol and could be regenerated at any point. This means that they could not be put into the QAT or if they did go in they could end up getting pulled out when the items were regenerated by the generator. Second, since these tools will not be direct children of the ribbon group (the itemscontrol will create a contentpresenter that will use the itemtemplate to create the element it will contain) they will not participate in the tool layout and so their size will always remain whatever is specified by the default template - RibbonGroup.(Minimum|Maximum)ToolSize will have no meaning.

    You may be able to create the tools yourself and bind a collection of the tools to the ItemsSource of the group. But you still could come across issues where any copies added to the qat could be removed and since the tools are not in the logical tree they won't get notifications from the framework when the theme changes.

Reply Children
No Data