自定义colorpicker

<ObjectDataProvider MethodName="GetType"   
                ObjectType="{x:Type system:Type}" x:Key="colorsTypeOdp">
            <ObjectDataProvider.MethodParameters>
                <system:String>System.Windows.Media.Colors, PresentationCore,  
            Version=4.0.0.0, Culture=neutral,   
            PublicKeyToken=31bf3856ad364e35</system:String>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <ObjectDataProvider ObjectInstance="{StaticResource colorsTypeOdp}" MethodName="GetProperties" x:Key="colorPropertiesOdp">
        </ObjectDataProvider>
        <Style x:Key="HongColorPickerItemStyle" TargetType="ComboBoxItem">
            <Setter Property="Margin" Value="1"></Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ComboBoxItem">
                        <Grid>
                            <Border BorderBrush="#FFC2C7CB" BorderThickness="1" Margin="1">
                                <Rectangle Fill="{Binding Name}" Width="20" Height="18"></Rectangle>
                            </Border>
                            <Rectangle x:Name="Temp_MouseOverRect" Visibility="Collapsed" Stroke="LightBlue" StrokeThickness="1"></Rectangle>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Visibility" TargetName="Temp_MouseOverRect" Value="Visible"></Setter>
                            </Trigger>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Visibility" TargetName="Temp_MouseOverRect" Value="Visible"></Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="HongColorPickerToggleButtonStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="IsTabStop" Value="false"/>
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="ClickMode" Value="Press"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
                            <!--<Grid HorizontalAlignment="Right" Width="32">
                                <Path x:Name="Arrow" Data="M 0 0 L 5 5 L 10 0 Z" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Center"  VerticalAlignment="Center"/>
                            </Grid>-->
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BorderBrush" TargetName="Bd" Value="#FF0D47A1"/>
                                <!--<Setter Property="Fill" TargetName="Arrow" Value="#FF0D47A1"/>-->
                            </Trigger>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter Property="BorderBrush" TargetName="Bd" Value="#FF0D47A1"/>
                                <!--<Setter Property="Fill" TargetName="Arrow" Value="#FF0D47A1"/>-->
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="BorderBrush" TargetName="Bd" Value="#FFAAAAAA"/>
                                <!--<Setter Property="Fill" TargetName="Arrow" Value="#FFAAAAAA"/>-->
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="HongColorPickerStyle" TargetType="{x:Type ComboBox}">
            <Setter Property="Foreground" Value="#FF525E66"/>
            <Setter Property="Background" Value="White"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="BorderBrush" Value="#FFC7C7C7"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="Padding" Value="10,0,0,0"/>
            <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
            <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
            <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
            <Setter Property="ItemsSource" Value="{Binding Source={StaticResource colorPropertiesOdp}}"></Setter>
            <Setter Property="SelectedValuePath" Value="Name"></Setter>
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <WrapPanel></WrapPanel>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemContainerStyle" Value="{StaticResource HongColorPickerItemStyle}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ComboBox}">
                        <Grid x:Name="MainGrid" SnapsToDevicePixels="true">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="32"/>
                            </Grid.ColumnDefinitions>
                            <Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" 
                                   IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"  
                                   PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
                                <Border x:Name="DropDownBorder" Background="White" BorderBrush="#FFC2C7CB" BorderThickness="1"  
                                        MaxHeight="{TemplateBinding MaxDropDownHeight}" 
                                        MinWidth="{Binding ActualWidth, ElementName=MainGrid}" 
                                        MaxWidth="300" Margin="1">
                                    <Border.Effect>
                                        <DropShadowEffect ShadowDepth="6" BlurRadius="12" Opacity="0.2" Direction="270"/>
                                    </Border.Effect>
                                    <Border x:Name="DropDownScrollViewer" Padding="0,2,0,0">
                                        <Grid RenderOptions.ClearTypeHint="Enabled">
                                            <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0" ClipToBounds="True">
                                                <Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" 
                                                       Height="{Binding ActualHeight, ElementName=DropDownBorder}" 
                                                       Width="{Binding ActualWidth, ElementName=DropDownBorder}"/>
                                            </Canvas>
                                            <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                        </Grid>
                                    </Border>
                                </Border>
                            </Popup>
                            <Rectangle Tag="{TemplateBinding SelectedValue}" Fill="{Binding RelativeSource={RelativeSource Self},Path=Tag}"
                                       HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1" Grid.ColumnSpan="2"></Rectangle>
                            <ToggleButton BorderBrush="{TemplateBinding BorderBrush}" Background="Transparent" Grid.ColumnSpan="2" 
                                          IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                          Style="{StaticResource HongColorPickerToggleButtonStyle}"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true"/>
                            <Trigger Property="HasItems" Value="false">
                                <Setter Property="Height" TargetName="DropDownBorder" Value="0"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource Disabled}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>