All widgets that take part in the ribbon layout implement the INRibbonWidget interface. It provides the following properties:
Setting Ribbon Button Initial State |
Copy Code
|
---|---|
ribbonButton.InitialState = ENRibbonWidgetState.Medium; |
Value | Description |
---|---|
Never | The widget never collapses. |
WhenParentIsMedium | The widget collapses when its parent is in medium state. |
WhenParentIsSmall | The widget collapses when its parent is in small state. |
By default the CollapseToMedium property is set to WhenParentIsMedium and CollapseToSmall property is set to WhenParentIsSmall, but you can change them when needed for any ribbon widget. Note that if you set the CollapseToMedium to Never, then the widget will always remain in it initial state - Large.
The INRibbonWidget interface also provides several methods, one of which is the GetSize method. It takes a state as a parameter and returns the size of the ribbon widget in this state. This method is used by the layout engine to determine how much space can be saved when collapsing the given widget from a larger to a smaller state. That is why it is very important to implement it correctly when you create custom widgets, which should take part in the ribbon layout.
When creating custom ribbon widgets, you can use the GetWidgetStateForGroupState and the OnInitialStateChanged static methods of the NRibbonHelpers class to help you with the implementation of the similarly named methods of the INRibbonWidget interface:
Using Helper Methods in Custom Ribbon Widget Implementations |
Copy Code
|
---|---|
public int GetStateForGroupState(int groupState) { return (int)NRibbonHelpers.GetWidgetStateForGroupState(this, groupState); } void INRibbonWidget.OnInitialStateChanged(NValueChangeData data) { NRibbonHelpers.OnInitialStateChanged(this); } |