User Interface / Widgets / Ribbon / Layout Engine / The INRibbonWidget Interface
In This Topic
    The INRibbonWidget Interface
    In This Topic

    All widgets that take part in the ribbon layout implement the INRibbonWidget interface. It provides the following properties:

    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);
    }
    
    See Also