Fluent.Ribbon禁用图标

时间:2016-08-25 07:42:32

标签: c# fluent-ribbon

我正在使用fluent:ToggleButton,但我无法找到如何禁用该图标。我没有使用它,它占据了我没有的地方。

是否有默认方式禁用它,还是需要做一些特别的事情?

Example

1 个答案:

答案 0 :(得分:2)

这是我的解决方法:

从“属性”窗口中,您可以将模板转换为新资源并删除ContentPresenter x:Name="iconImage"

用法

<!--Tabs-->
<Fluent:RibbonTabItem Header="Tab">
    <Fluent:RibbonGroupBox Header="Group">
        <Fluent:ToggleButton Height="30" x:Name="buttonGreen" VerticalContentAlignment="Center" 
                       VerticalAlignment="Top" Header="NoIcon" Template="{DynamicResource NoIconToggleButtonControlTemplate}" />

使用自动生成的资源(删除图标后)

<fluent:RibbonWindow.Resources>
    <ControlTemplate x:Key="NoIconToggleButtonControlTemplate" TargetType="{x:Type fluent:ToggleButton}">
        <Border x:Name="border" BorderBrush="{DynamicResource TransparentBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{DynamicResource TransparentBrush}" HorizontalAlignment="Left" Height="Auto" VerticalAlignment="Stretch">
            <Grid Height="Auto">
                <StackPanel x:Name="stackPanel" Orientation="Vertical" Width="Auto">
                    <fluent:TwoLineLabel x:Name="controlLabel" Focusable="False" HorizontalAlignment="Stretch" Margin="2,-3,2,1" Style="{DynamicResource TwoLineLabelStyle}" Text="{TemplateBinding Header}" VerticalAlignment="Stretch"/>
                </StackPanel>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Size" Value="Small">
                <Setter Property="Orientation" TargetName="stackPanel" Value="Horizontal"/>
                <Setter Property="Visibility" TargetName="controlLabel" Value="Collapsed"/>
                <Setter Property="HasTwoLines" TargetName="controlLabel" Value="False"/>
                <Setter Property="Margin" TargetName="controlLabel" Value="2,-2,2,2"/>
            </Trigger>
            <Trigger Property="Size" Value="Middle">
                <Setter Property="Orientation" TargetName="stackPanel" Value="Horizontal"/>
                <Setter Property="Width" TargetName="stackPanel" Value="Auto"/>
                <Setter Property="HasTwoLines" TargetName="controlLabel" Value="False"/>
                <Setter Property="Margin" TargetName="controlLabel" Value="2"/>
                <Setter Property="VerticalAlignment" TargetName="border" Value="Stretch"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
                <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonPressedOuterBackgroundBrush}"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonCheckedBrush}"/>
                <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonCheckedBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" TargetName="controlLabel" Value="0.5"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True"/>
                    <Condition Property="IsPressed" Value="False"/>
                </MultiTrigger.Conditions>
                <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}"/>
                <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True"/>
                    <Condition Property="IsPressed" Value="False"/>
                    <Condition Property="IsChecked" Value="True"/>
                </MultiTrigger.Conditions>
                <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}"/>
                <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
</fluent:RibbonWindow.Resources>