小编MrW*_*fle的帖子

在 fluentribbon 按钮中设置 xaml 图标

我使用fluentribbonmahapps作为我的 GUI,并希望在我的功能区中有一个带有图标的按钮。我想用XAML的图标,如(而不是一个文件)。所以我需要在 fluent:Button 中设置 Path。我尝试了以下但它不工作 - 按钮是空白的(没有文字和图标显示):

<fluent:Button Name="Test">
    <StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Center">
        <Path Width="40" Height="40" Stretch="Uniform" UseLayoutRounding="False" Fill="Black" Data="..."/>
        <TextBlock><Run Text="Test Button"/></TextBlock>
    </StackPanel>
</fluent:Button>
Run Code Online (Sandbox Code Playgroud)

更新

这是完整的代码:

<Controls:MetroWindow  x:Class="RibbonTestProj.View.RibbonTest"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
        xmlns:fluent="urn:fluent-ribbon"
        Title="Ribbon Test" Height="474" Width="849" MinHeight="300" MinWidth="400" >
    <Grid>
        <fluent:Ribbon CanMinimize="False" CanQuickAccessLocationChanging="False" AutomaticStateManagement="false"
                       x:Name="ribbon">
            <fluent:RibbonTabItem   x:Name="test1TabItem"
                                    Header="Test1"
                                    KeyTip="I">
                <fluent:RibbonGroupBox Header="Group1" Height="84" Width="248" TabIndex="0">
                    <fluent:Button Name="Test">
                        <StackPanel VerticalAlignment="Stretch"
                                HorizontalAlignment="Center">
                            <Path Width="40"
                                Height="40"
                                Stretch="Uniform"
                                Fill="Black"
                                Data="M 10,100 C 10,300 300,-200 300,100" />
                            <TextBlock><Run Text="Test Button" …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml ribbon fluent-ribbon

3
推荐指数
1
解决办法
2570
查看次数

标签 统计

c# ×1

fluent-ribbon ×1

ribbon ×1

wpf ×1

xaml ×1