为什么功能区项目未显示在窗口上?

问题描述 投票:0回答:1

我正在使用.NET Core 3.1开发应用程序。添加对Fluent Ribbon的引用,但是当我编写一些XAML时,没有任何显示。

<Window x:Class="WpfApp2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp2"
        xmlns:fluent="urn:fluent-ribbon"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <fluent:Ribbon>
            <fluent:Ribbon.Menu>
                <fluent:Backstage>
                    <fluent:BackstageTabControl>
                        <fluent:BackstageTabItem Header="Database">
                            <WrapPanel Orientation="Horizontal">
                                <WrapPanel Orientation="Vertical">
                                    <fluent:Button Header="Open Database" Foreground="Black" />
                                    <fluent:Button Header="Save Database" Foreground="Black" />
                                    <fluent:Button Header="Do something" Foreground="Black" />
                                </WrapPanel>
                                <fluent:TextBox Header="Database Name" Text="Your Database" Foreground="Black"/>
                            </WrapPanel>
                        </fluent:BackstageTabItem>
                        <fluent:Button x:Name="ExitButton" Header="Exit"  />
                    </fluent:BackstageTabControl>
                </fluent:Backstage>
            </fluent:Ribbon.Menu>
        </fluent:Ribbon>
    </Grid>
</Window>

知道我在做什么错吗?

c# wpf ribbon
1个回答
0
投票

您似乎未在Ribbon中添加任何项目。您只设置了Menu属性。

尝试像在RibbonTabItem中一样将Ribbon添加到this basic setup

<Fluent:RibbonWindow x:Class="MyFirstRibbonProject.MyFirstWindow"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:Fluent="urn:fluent-ribbon"
                     Title="My first RibbonWindow" 
                     Width="800" 
                     Height="600">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Fluent:Ribbon Grid.Row="0">
            <!--Backstage-->
            <Fluent:Ribbon.Menu>
                <Fluent:Backstage>
                </Fluent:Backstage>
            </Fluent:Ribbon.Menu>

            <!--Tabs-->
            <Fluent:RibbonTabItem Header="Home">
                <Fluent:RibbonGroupBox Header="Group">
                    <Fluent:Button Header="Green"
                                Icon="Resource-Path to your small icon for this button"
                                LargeIcon="Resource-Path to your large icon for this button" />
                    <Fluent:Button Header="Grey" 
                                Icon="Resource-Path to your small icon for this button"
                                LargeIcon="Resource-Path to your large icon for this button" />
                </Fluent:RibbonGroupBox>
            </Fluent:RibbonTabItem>
        </Fluent:Ribbon>

        <Grid Grid.Row="1">
            <TextBlock>My first window containing a Ribbon and something else.</TextBlock>
        </Grid>
    </Grid>
</Fluent:RibbonWindow>
© www.soinside.com 2019 - 2024. All rights reserved.