自定义colorpicker
"GetType"
ObjectType="{x:Type system:Type}" x:Key="colorsTypeOdp">
String>System.Windows.Media.Colors, PresentationCore,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35 String>
"{StaticResource colorsTypeOdp}" MethodName="GetProperties" x:Key="colorPropertiesOdp">
<Style x:Key="HongColorPickerItemStyle" TargetType="ComboBoxItem">
<Setter Property="Margin" Value="1">Setter>
<Setter Property="Template">
<Setter.Value>
"ComboBoxItem">
<Grid>
"#FFC2C7CB" BorderThickness="1" Margin="1">
<Rectangle Fill="{Binding Name}" Width="20" Height="18">Rectangle>
<Rectangle x:Name="Temp_MouseOverRect" Visibility="Collapsed" Stroke="LightBlue" StrokeThickness="1">Rectangle>
Grid>
<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>
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>
"{x:Type ToggleButton}">
"Bd" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="Bd" Value="#FF0D47A1"/>
Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="BorderBrush" TargetName="Bd" Value="#FF0D47A1"/>
Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="BorderBrush" TargetName="Bd" Value="#FFAAAAAA"/>
Trigger>
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>
Setter.Value>
Setter>
<Setter Property="ItemContainerStyle" Value="{StaticResource HongColorPickerItemStyle}"/>
<Setter Property="Template">
<Setter.Value>
"{x:Type ComboBox}">
<Grid x:Name="MainGrid" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
"*"/>
"{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="32"/>
Grid.ColumnDefinitions>
"PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2"
IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
"DropDownBorder" Background="White" BorderBrush="#FFC2C7CB" BorderThickness="1"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{Binding ActualWidth, ElementName=MainGrid}"
MaxWidth="300" Margin="1">
"6" BlurRadius="12" Opacity="0.2" Direction="270"/>
"DropDownScrollViewer" Padding="0,2,0,0">
<Grid RenderOptions.ClearTypeHint="Enabled">
"ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
Grid>
<Rectangle Tag="{TemplateBinding SelectedValue}" Fill="{Binding RelativeSource={RelativeSource Self},Path=Tag}"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1" Grid.ColumnSpan="2">Rectangle>
"{TemplateBinding BorderBrush}" Background="Transparent" Grid.ColumnSpan="2"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource HongColorPickerToggleButtonStyle}"/>
Grid>
<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>
Setter.Value>
Setter>
Style>