RibbonButton在WPF中的Ribbon控件中未正确对齐

时间:2012-01-03 04:04:51

标签: wpf controls ribbon

我正在为我的应用程序创建功能区控件,我已经编写了大部分代码。我面临的唯一问题是我添加到选项卡的功能区按钮未在选项卡中正确对齐。正如您在屏幕截图中看到的那样,按钮正在与标签的底部对齐。如何将这些按钮置于顶部以便可见。

RibbonControl and XMAL

这是我的应用程序的样子

enter image description here

XAML代码位于

之下
<UserControl x:Class="SongPurifier.UserControls.RibbonControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:ribbon="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
        >
<Grid>
    <ribbon:Ribbon x:Name="ribbon" VerticalAlignment="Top">
        <ribbon:RibbonTab Header="Home">
            <ribbon:RibbonSplitButton  
                Label="Open" 
                LargeImageSource="/Images/Folder Open.png"
                Command="{Binding OpenFolderCommand}">
            </ribbon:RibbonSplitButton>
        </ribbon:RibbonTab>

        <ribbon:RibbonTab Header="Edit" >
            <ribbon:RibbonButton Label="Replace String" 
                                 LargeImageSource="/Images/Find Replace.png"
                                 Command="{Binding EditSongInfoCommand}"
                                 >
            </ribbon:RibbonButton >

            <ribbon:RibbonButton Label="Update Song Info"
                                 LargeImageSource="/Images/Update.png"
                                 Command="{Binding UpdateSongInfoCommand}"
                                 >
            </ribbon:RibbonButton>
        </ribbon:RibbonTab>
        <ribbon:RibbonTab Header="Update" >
            <ribbon:RibbonButton 
                Label="Check for Update" >

            </ribbon:RibbonButton>
        </ribbon:RibbonTab>
    </ribbon:Ribbon>
</Grid>

1 个答案:

答案 0 :(得分:1)

萨钦: 将Ribbon Buttons放在RibbonGroup中。

<my:RibbonTab Header="Home">
    <my:RibbonGroup Header="File">
        <ribbon:RibbonSplitButton  
            Label="Open" 
            LargeImageSource="/Images/Folder Open.png"
            Command="{Binding OpenFolderCommand}">
        </ribbon:RibbonSplitButton>
    </my:RibbonGroup>
</my:RibbonTab>