Loading...
Loading...
Compare original and translation side by side
SfColorPickerSfColorPickerusing Syncfusion.UI.Xaml.Editors;Syncfusion.Editors.WinUIusing Syncfusion.UI.Xaml.Editors;Syncfusion.Editors.WinUISfColorPickerSyncfusion.Editors.WinUISfColorPickerSyncfusion.Editors.WinUISelectedBrushColorChannelOptionsBrushTypeOptionsAlphaInputOptionsIsHexInputVisibleColorChannelInputOptionsColorEditorsVisibilityModeSelectedBrushChangedSelectedBrushColorChannelOptionsBrushTypeOptionsAlphaInputOptionsIsHexInputVisibleColorChannelInputOptionsColorEditorsVisibilityModeSelectedBrushChangedLinearGradientBrushGradientStopStartPointEndPointRadialGradientBrushGradientOriginCenterRadiusXRadiusYBrushTypeOptionsAxisInputOptionSelectedBrushChangedLinearGradientBrushGradientStopStartPointEndPointRadialGradientBrushGradientOriginCenterRadiusXRadiusYBrushTypeOptionsAxisInputOptionSelectedBrushChangedBrushTypeOptionsBrushTypeOptionsColorSpectrumShapeColorSpectrumComponentsBrushTypeOptionsBrushTypeOptionsColorSpectrumShapeColorSpectrumComponents<Page
x:Class="ColorPickerApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:editors="using:Syncfusion.UI.Xaml.Editors">
<Grid>
<editors:SfColorPicker
x:Name="colorPicker"
SelectedBrush="Blue"
BrushTypeOptions="All"
SelectedBrushChanged="ColorPicker_SelectedBrushChanged" />
</Grid>
</Page><Page
x:Class="ColorPickerApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:editors="using:Syncfusion.UI.Xaml.Editors">
<Grid>
<editors:SfColorPicker
x:Name="colorPicker"
SelectedBrush="Blue"
BrushTypeOptions="All"
SelectedBrushChanged="ColorPicker_SelectedBrushChanged" />
</Grid>
</Page>using Syncfusion.UI.Xaml.Editors;
using Microsoft.UI.Xaml.Media;
private void ColorPicker_SelectedBrushChanged(object sender, SelectedBrushChangedEventArgs args)
{
if (args?.NewBrush is SolidColorBrush solidBrush)
{
var color = solidBrush.Color; // Access R, G, B, A
}
else if (args?.NewBrush is LinearGradientBrush linearBrush)
{
var stops = linearBrush.GradientStops;
}
else if (args?.NewBrush is RadialGradientBrush radialBrush)
{
var stops = radialBrush.GradientStops;
}
}using Syncfusion.UI.Xaml.Editors;
using Microsoft.UI.Xaml.Media;
private void ColorPicker_SelectedBrushChanged(object sender, SelectedBrushChangedEventArgs args)
{
if (args?.NewBrush is SolidColorBrush solidBrush)
{
var color = solidBrush.Color; // 访问R、G、B、A通道
}
else if (args?.NewBrush is LinearGradientBrush linearBrush)
{
var stops = linearBrush.GradientStops;
}
else if (args?.NewBrush is RadialGradientBrush radialBrush)
{
var stops = radialBrush.GradientStops;
}
}<editors:SfColorPicker
BrushTypeOptions="SolidColorBrush"
ColorChannelOptions="RGB"
IsHexInputVisible="True" /><editors:SfColorPicker
BrushTypeOptions="SolidColorBrush"
ColorChannelOptions="RGB"
IsHexInputVisible="True" /><editors:SfColorPicker
BrushTypeOptions="LinearGradientBrush,RadialGradientBrush"
AxisInputOption="Simple" /><editors:SfColorPicker
BrushTypeOptions="LinearGradientBrush,RadialGradientBrush"
AxisInputOption="Simple" />// Solid color
colorPicker.SelectedBrush = new SolidColorBrush(Colors.Red);
// Linear gradient
var linearGradient = new LinearGradientBrush();
linearGradient.StartPoint = new Point(0, 0);
linearGradient.EndPoint = new Point(1, 1);
linearGradient.GradientStops.Add(new GradientStop() { Color = Colors.Yellow, Offset = 0.0 });
linearGradient.GradientStops.Add(new GradientStop() { Color = Colors.Red, Offset = 1.0 });
colorPicker.SelectedBrush = linearGradient;// 纯色
colorPicker.SelectedBrush = new SolidColorBrush(Colors.Red);
// 线性渐变
var linearGradient = new LinearGradientBrush();
linearGradient.StartPoint = new Point(0, 0);
linearGradient.EndPoint = new Point(1, 1);
linearGradient.GradientStops.Add(new GradientStop() { Color = Colors.Yellow, Offset = 0.0 });
linearGradient.GradientStops.Add(new GradientStop() { Color = Colors.Red, Offset = 1.0 });
colorPicker.SelectedBrush = linearGradient;<editors:SfColorPicker
ColorSpectrumShape="Ring"
ColorSpectrumComponents="HueSaturation" /><editors:SfColorPicker
ColorSpectrumShape="Ring"
ColorSpectrumComponents="HueSaturation" />| Property | Type | Default | Purpose |
|---|---|---|---|
| Brush | Blue | Gets/sets the selected color brush |
| BrushTypeOptions | All | Enables specific brush modes (Solid, Linear, Radial) |
| ColorChannelOptions | RGB | Sets color model (RGB, HSV, HSL, CMYK) |
| ColorSpectrumShape | Box | Sets spectrum shape (Box or Ring) |
| ColorSpectrumComponents | SaturationValue | Defines spectrum axes |
| ColorInputOptions | All | Controls alpha/opacity input visibility |
| bool | true | Shows/hides hexadecimal editor |
| ColorInputOptions | All | Controls channel input type (Slider/Text/All) |
| ColorEditorsVisibilityMode | Inline | Sets editor visibility (Inline/Expandable/Collapsed) |
| AxisInputOption | Simple | Controls gradient axis input complexity |
| 属性 | 类型 | 默认值 | 用途 |
|---|---|---|---|
| Brush | Blue | 获取/设置选中的颜色画刷 |
| BrushTypeOptions | All | 启用特定画刷模式(纯色、线性、径向) |
| ColorChannelOptions | RGB | 设置颜色模型(RGB、HSV、HSL、CMYK) |
| ColorSpectrumShape | Box | 设置色谱形状(矩形或环形) |
| ColorSpectrumComponents | SaturationValue | 定义色谱坐标轴 |
| ColorInputOptions | All | 控制alpha/透明度输入的可见性 |
| bool | true | 显示/隐藏十六进制编辑器 |
| ColorInputOptions | All | 控制颜色通道输入类型(滑块/文本/全部) |
| ColorEditorsVisibilityMode | Inline | 设置编辑器可见性(内联/可展开/折叠) |
| AxisInputOption | Simple | 控制渐变坐标轴输入的复杂度 |
| Event | Args | Purpose |
|---|---|---|
| SelectedBrushChangedEventArgs | Fired when selected brush changes |
OldBrushNewBrush| 事件 | 参数 | 用途 |
|---|---|---|
| SelectedBrushChangedEventArgs | 当选中的画刷发生变化时触发 |
OldBrushNewBrush