문제

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