RibbonButton 在 WPF 的 Ribbon Control 中未正确对齐

发布于 2024-12-23 18:02:31 字数 2113 浏览 0 评论 0原文

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

RibbonControl 和 XMAL

这是我的应用程序的样子

在此处输入图像描述

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>

I am creating Ribbon Control for my application and for which I have already written most of code . The only problem I am facing is that the Ribbon Buttons I am adding to the Tabs are not aligning properly in the Tab . As you can see in the Screen Shot the button is aligning to bottom of the Tab. How can I bring these button to top so they are visible.

RibbonControl and XMAL

This is How my app looks like

enter image description here

The XAML Code is below

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

時窥 2024-12-30 18:02:31

萨钦:
将功能区按钮放置在功能区组内。

<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>

Sachin:
Place your Ribbon Buttons inside a 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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文