我将fluentribbon和mahapps用于我的GUI,并希望功能区中有一个带有图标的按钮.我想使用xaml图标,例如this(不是文件).所以我需要在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>
更新资料
这是完整的代码:
<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" /></TextBlock>
</StackPanel>
</fluent:Button>
</fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Group2" VerticalAlignment="Stretch" Height="84" Width="98" TabIndex="1">
</fluent:RibbonGroupBox>
</fluent:RibbonTabItem>
<fluent:RibbonTabItem x:Name="test2TabItem"
Header="Test2"
KeyTip="O">
</fluent:RibbonTabItem>
</fluent:Ribbon>
</Grid>
</Controls:MetroWindow>
以及它的外观(按钮在那里,我可以单击它,但是没有文本,也没有图标)
解决方法:
回复晚了非常抱歉.我花了一些时间才能运行该库.看来您可以设定LargeIcon
<fluent:Button Name="Test">
<fluent:Button.LargeIcon>
<Path Width="40"
Height="40"
Stretch="Uniform"
Fill="Black"
Data="M 10,100 C 10,300 300,-200 300,100" />
</fluent:Button.LargeIcon>
Test Button 1
</fluent:Button>
不要忘记:您始终可以提取控件的默认模板.然后,您可以查找控件的内部构造方式. How to Extract Default Control Template In Visual Studio?