Merge pull request #82 from dotnet/fix-79
Implement Color property in CheckBox
This commit is contained in:
Коммит
504ade99e3
|
@ -107,7 +107,7 @@ namespace GraphicsControls.Sample
|
|||
layout.Children.Add(new CheckBox { IsEnabled = false, IsChecked = true });
|
||||
|
||||
layout.Children.Add(new Label { FontSize = 9, TextColor = Colors.Gray, Text = "Custom" });
|
||||
layout.Children.Add(new CheckBox { BackgroundColor = Colors.Purple, IsChecked = true });
|
||||
layout.Children.Add(new CheckBox { Color = Colors.Purple, IsChecked = true });
|
||||
|
||||
return CreateContainer("CheckBox", layout);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
<Label Text="Disabled Button" Style="{StaticResource InfoLabel}"/>
|
||||
<CheckBox IsChecked="True" IsEnabled="False" />
|
||||
<Label Text="Custom Button" Style="{StaticResource InfoLabel}"/>
|
||||
<CheckBox IsChecked="True" BackgroundColor="Purple" />
|
||||
<CheckBox IsChecked="True" Color="Purple" />
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
|
|
|
@ -18,7 +18,8 @@ namespace Microsoft.Maui.Graphics.Controls
|
|||
|
||||
public static PropertyMapper<ICheckBox> PropertyMapper = new PropertyMapper<ICheckBox>(ViewHandler.Mapper)
|
||||
{
|
||||
[nameof(ICheckBox.IsChecked)] = ViewHandler.MapInvalidate
|
||||
[nameof(ICheckBox.IsChecked)] = ViewHandler.MapInvalidate,
|
||||
[nameof(ICheckBox.Foreground)] = ViewHandler.MapInvalidate,
|
||||
};
|
||||
|
||||
public static DrawMapper<ICheckBoxDrawable, ICheckBox> DrawMapper = new DrawMapper<ICheckBoxDrawable, ICheckBox>(ViewHandler.DrawMapper)
|
||||
|
|
|
@ -15,7 +15,12 @@
|
|||
|
||||
if (checkBox.IsChecked)
|
||||
{
|
||||
canvas.FillColor = checkBox.IsEnabled ? Cupertino.Color.SystemColor.Light.Blue.ToColor() : Cupertino.Color.SystemGray.Light.InactiveGray.ToColor();
|
||||
Color fillColor = checkBox.IsEnabled ? Cupertino.Color.SystemColor.Light.Blue.ToColor() : Cupertino.Color.SystemGray.Light.InactiveGray.ToColor();
|
||||
|
||||
if (checkBox.Foreground is SolidPaint solidPaint)
|
||||
fillColor = solidPaint.Color;
|
||||
|
||||
canvas.FillColor = fillColor;
|
||||
canvas.FillEllipse(x, y, size, size);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -16,7 +16,14 @@
|
|||
if (checkBox.IsChecked)
|
||||
{
|
||||
if (checkBox.IsEnabled)
|
||||
canvas.FillColor = Fluent.Color.Primary.ThemePrimary.ToColor();
|
||||
{
|
||||
Color fillColor = Fluent.Color.Primary.ThemePrimary.ToColor();
|
||||
|
||||
if (checkBox.Foreground is SolidPaint solidPaint)
|
||||
fillColor = solidPaint.Color;
|
||||
|
||||
canvas.FillColor = fillColor;
|
||||
}
|
||||
else
|
||||
canvas.FillColor = Fluent.Color.Background.NeutralQuaternaryAlt.ToColor();
|
||||
|
||||
|
|
|
@ -18,7 +18,14 @@ namespace Microsoft.Maui.Graphics.Controls
|
|||
if (checkBox.IsChecked)
|
||||
{
|
||||
if (checkBox.IsEnabled)
|
||||
canvas.FillColor = Material.Color.Blue.ToColor();
|
||||
{
|
||||
Color fillColor = Material.Color.Blue.ToColor();
|
||||
|
||||
if (checkBox.Foreground is SolidPaint solidPaint)
|
||||
fillColor = solidPaint.Color;
|
||||
|
||||
canvas.FillColor = fillColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Application.Current?.RequestedTheme == OSAppTheme.Light)
|
||||
|
|
Загрузка…
Ссылка в новой задаче