سؤال

I have RibbonControlGroup with a few buttons.

<r:RibbonControlGroup>
    <r:RibbonToggleButton Label="button1"/>
    <r:RibbonToggleButton Label="button2"/>
</r:RibbonControlGroup>

On Ribbon buttons are arranged horizontally. Like (button1|button2). How to arrange the buttons vertically?

هل كانت مفيدة؟

المحلول

I know, that I'm late to party, but may be this will help someone.
Since the RibbonControlGroup is an ItemsControl, the right way to go is to replace ItemsPanel like this:

<r:RibbonControlGroup>
    <r:RibbonControlGroup.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Vertical" />
        </ItemsPanelTemplate>
    </r:RibbonControlGroup.ItemsPanel>

    <!-- Group items are listed below: -->
    <r:RibbonToggleButton Label="button1"/>
    <r:RibbonToggleButton Label="button2"/>
</r:RibbonControlGroup>

This approach conceptually differs from @Sajeetharan's answer, because he creates a group with a single child - StackPanel, while my sample still is an equivalent of the code, posted in the question: here's a group with two children of type RibbonToggleButton.

The difference will be meaningful with data binding scenarios, when items of group be populated dynamically through data binding expression.

نصائح أخرى

You can keep these controls in a container and set its Orientation property to "Vertical" For e.g. using StackPanel as a container

will place the buttons vertically

Use StackPanel and change the orientation to Vertical ,

 <r:RibbonControlGroup>
            <StackPanel Orientation="Vertical">
            <r:RibbonToggleButton Label="button1"/>
            <r:RibbonToggleButton Label="button2"/>
            </StackPanel>
 </r:RibbonControlGroup>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top