Custom Controls in Ribbon

Ribbon for WPF Forum

Posted 15 years ago by Leighton Haynes
Version: 4.5.0485
Avatar
I'm currently evaluating the actipro ribbon, and one of our requirements is the ability to place out own custom controls in the ribbon and have them behave well with respect to resizing - that is, we'd like to be able to set a minimum, and maximum size, and have them interact with the normal resizing capabilities and be sorted as other controls are in the ribbon.

I can't find an example of this anywhere. As a concrete example, say I wanted to put a control in the ribbon, and set it so that it was sized 100x60 at large size, 100x20 at medium size and 40x20 at small size, how would I do it?

Cheers,
Leighton...

Comments (4)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Leighton,

Thanks for evaluating Ribbon! We haven't made a sample to show this but you definitely should be able to do it.

First, I'd recommend using a ribbon:StackPanel within a ribbon:Group, just like we do with a lot of buttons in our demos. The ribbon:StackPanel will transition its items from various VariantSize's as size increases/decreases. So you'd end up putting the control you develop (see below) within a ribbon:StackPanel.

Then make a control that inherits ribbon:ControlBase. Our ribbon buttons all indirectly inherit ribbon:ControlBase. In your case you could make your control inherit it directly or you could maybe make a control that inherits it but allows another control to be embedded in it.

Then in your Style for the control that inherits ribbon:ControlBase, add triggers in the Template so that for different VariantSize settings (Large, Medium, Small) it will switch to different Width/Height settings, etc.

By doing those things, it should work. If you give it a try and get it going with a simple sample, maybe email a simple project over showing it and perhaps we can polish it and make a QuickStart for future builds.


Actipro Software Support

Posted 15 years ago by Leighton Haynes
Avatar
Thanks for that. I managed to produce a proof on concept by inheriting from ControlBase and overriding OnVariantSizeChanged() - most of our code is not XAML based, due to some unusual design decision.
Posted 15 years ago by Leighton Haynes
Avatar
Ok, I have a followup question now :)

If I want to create a control which was to resize like the Gallery - can I do it? The method I'm using above doesn't work, as the groups don't seem to change the variant size of controls hosted directly inside them.

Also, (and I suspect this may be the same answer) - how do I create my own panel control and have it interact with the GroupVariant resizing?

Thanks,
Leighton...
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Leighton,

Probably not unfortunately. Groups right now will default to keeping child controls at a Large variant size. However RowPanel, StackPanel, and RibbonGallery are special cased to transition their VariantSize based on the Group's current variant size.

One thing we could possibly do would be to make an interface that those 3 controls would implement to support this behavior. Then you could make a custom panel that would support the interface and get similar behavior.

Since you are still evaluating and aren't sure if you will choose our product yet, let us know if you do commit to our ribbon, and in that case perhaps we can add this feature for you.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.