我为本帖末尾显示的Ribbon按钮创建了一个ControlTemplate。
它显示正常,但我会有像标准按钮这样的标签。当我使用我的控件模板添加一个按钮并添加Label =" blah"没有显示 - 我需要编辑我的控件模板吗?
还有一种方法可以更改功能区按钮在功能区上占用的大小,因为它有点小吗?
标准按钮
<RibbonButton Label="Recalculate Values"
Command="{Binding CommandButtCalcHlds}"
IsEnabled="{Binding ButtHome}"
LargeImageSource="MyPath\Calculate1.jpg"/>
使用我的控件模板按钮
<RibbonButton Command="{Binding CommandButtHldChk}"
IsEnabled="{Binding ButtExportToExcel}"
Template="{StaticResource buttRibbonCheck}"/>
我的控制模板
<ControlTemplate x:Key="buttRibbonCheck" TargetType="{x:Type RibbonButton}">
<Grid Height="60" Width="60">
<Ellipse Name="outerCircle" >
<Ellipse.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="Blue"/>
<GradientStop Offset="1" Color="Red"/>
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse Margin="5">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Offset="0" Color="White"/>
<GradientStop Offset="1" Color="Transparent"/>
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<TextBlock Text="Check" FontWeight="Bold" FontSize="18" Padding="2" LineHeight="20"
HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="outerCircle" Property="Fill" Value="Purple"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX=".9" ScaleY=".9"/>
</Setter.Value>
</Setter>
<Setter Property="RenderTransformOrigin" Value=".5,.5"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
答案 0 :(得分:0)
设置功能区按钮的边距
<RibbonTab Header="Insert">
<RibbonButton Command="{Binding CommandButtHldChk}" VerticalAlignment="Top" Margin="0,-50,0,0"
IsEnabled="{Binding ButtExportToExcel}"
Template="{StaticResource buttRibbonCheck}" />
</RibbonTab>
或使用
<RibbonGroup>
<RibbonButton Command="{Binding CommandButtHldChk}"
IsEnabled="{Binding ButtExportToExcel}"
Template="{StaticResource buttRibbonCheck}"/>
</RibbonGroup >