C# 如何为颜色选择器(wpf)创建颜色画布
我想在Visual Studio或Blend或here()中创建自定义颜色选择器。 我有个问题。我不知道如何在上面的链接中创建彩色画布。(可能不是画布,而是别的东西) 我看起来像一块有着不同寻常的梯度的画布。。。我不知道如何在xaml中实现它。我试图在Visual Studio中绘制它,但没有成功。。。。 任何帮助都将不胜感激C# 如何为颜色选择器(wpf)创建颜色画布,c#,wpf,canvas,color-picker,C#,Wpf,Canvas,Color Picker,我想在Visual Studio或Blend或here()中创建自定义颜色选择器。 我有个问题。我不知道如何在上面的链接中创建彩色画布。(可能不是画布,而是别的东西) 我看起来像一块有着不同寻常的梯度的画布。。。我不知道如何在xaml中实现它。我试图在Visual Studio中绘制它,但没有成功。。。。 任何帮助都将不胜感激 提前感谢可以使用常规的LinearGradientBrush创建色调栏。“级别/饱和度”面板可以使用适当颜色的LinearGradientBrush沿X轴绘制,另一个作为
提前感谢可以使用常规的
LinearGradientBrush
创建色调栏。“级别/饱和度”面板可以使用适当颜色的LinearGradientBrush
沿X轴绘制,另一个作为沿Y轴绘制的不透明度遮罩,整个画面在黑色背景下绘制
<Window.Resources>
<!-- Change this to any pure hue i.e. no more than 2 rgb components set and at least 1 set to FF -->
<Color x:Key="CurrentColor">#00FF00</Color>
<LinearGradientBrush x:Key="HueBrush" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FF0000" Offset="0" />
<GradientStop Color="#FFFF00" Offset="0.167" />
<GradientStop Color="#00FF00" Offset="0.333" />
<GradientStop Color="#00FFFF" Offset="0.5" />
<GradientStop Color="#0000FF" Offset="0.667" />
<GradientStop Color="#FF00FF" Offset="0.833" />
<GradientStop Color="#FF0000" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<VisualBrush x:Key="LevelSaturationBrush" TileMode="None">
<VisualBrush.Visual>
<Canvas Background="Black" Width="1" Height="1" SnapsToDevicePixels="True">
<Rectangle Width="1" Height="1" SnapsToDevicePixels="True">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<LinearGradientBrush.GradientStops>
<GradientStop Color="White" Offset="0" />
<GradientStop Color="{DynamicResource CurrentColor}" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.OpacityMask>
</Rectangle>
</Canvas>
</VisualBrush.Visual>
</VisualBrush>
</Window.Resources>
<StackPanel Orientation="Horizontal">
<Rectangle Fill="{StaticResource LevelSaturationBrush}" Width="200" Height="200" Margin="10" Stroke="Black" StrokeThickness="1" SnapsToDevicePixels="True" />
<Rectangle Fill="{StaticResource HueBrush}" Width="20" Height="200" Margin="10" Stroke="Black" StrokeThickness="1" SnapsToDevicePixels="True" />
</StackPanel>
#00FF00
结果:
为什么你不能直接使用它,或者根据自己的需求修改源代码?@GlenThomas,好主意,但我找不到它的源代码。。。。是同一颜色的来源吗picker@GlenThomas谢谢非常感谢。这就是我要找的。我需要检查一下。