在xceed工具箱ColorPicker中隐藏向下箭头

问题描述

我在WPF项目中使用Xceed Toolkit ColorPicker。拾色器运行良好,但找不到隐藏组合框样式向下箭头的选项。

我正在寻找一种编辑模板并将其隐藏的方法。

  xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"

       <xctk:ColorPicker Name="cp" 
                       DisplayColorAndName="False" 
                       Height="25"
                       Width="70"
                       SelectedColorChanged="cp_SelectedColorChanged_1" 
                       AvailableColorsSortingMode="HueSaturationBrightness" >            
    </xctk:ColorPicker>

我只是想知道是否有人可以共享有效的XAML模板代码。

enter image description here

解决方法

您不必编辑模板,可以将react-navigation属性设置为ShowDropDownButton

false

这将导致<xctk:ColorPicker Name="cp" DisplayColorAndName="False" Height="25" Width="70" AvailableColorsSortingMode="HueSaturationBrightness" ShowDropDownButton="False"> </xctk:ColorPicker> 的箭头不显示。

enter image description here

,

如果您使用的版本中没有ShowDropDownButton属性,则创建自定义ButtonStyle应该可以解决问题:

您应该使用自定义的ButtonStyle

<xctk:ColorPicker Name="cp" 
                  DisplayColorAndName="False" 
                  Height="25"
                  Width="70"
                  SelectedColorChanged="cp_SelectedColorChanged_1" 
                  AvailableColorsSortingMode="HueSaturationBrightness" >
    <xctk:ColorPicker.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </xctk:ColorPicker.Resources>
    <xctk:ColorPicker.ButtonStyle>
        <Style TargetType="ToggleButton">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ToggleButton" xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes;assembly=Xceed.Wpf.Toolkit">
                        <Grid SnapsToDevicePixels="True">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <Border Background="{TemplateBinding Background}"
                                        BorderBrush="{TemplateBinding BorderBrush}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        Padding="{TemplateBinding Padding}"
                                        SnapsToDevicePixels="True">
                                    <ContentPresenter Content="{TemplateBinding Content}"
                                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                                    ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                                </Border>
                                <chrome:ButtonChrome x:Name="ToggleButtonChrome"
                                                    Grid.Column="1"
                                                    CornerRadius="0,2.75,0"
                                                    Visibility="{Binding ShowDropDownButton,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=xctk:ColorPicker},Converter={StaticResource BooleanToVisibilityConverter}}"
                                                    RenderChecked="{Binding IsOpen,AncestorType=xctk:ColorPicker}}"
                                                    RenderEnabled="{Binding IsEnabled,AncestorType=xctk:ColorPicker}}"
                                                    RenderMouseOver="{TemplateBinding IsMouseOver}"
                                                    RenderPressed="{TemplateBinding IsPressed}">
                                </chrome:ButtonChrome>
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </xctk:ColorPicker.ButtonStyle>
</xctk:ColorPicker>

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...