小编Shi*_* MC的帖子

更改Xamarin表单按钮颜色

我是xamarin的新手,我想在完成一个过程后返回默认颜色后更改按钮的颜色,请参阅下面的代码如何在运行时重新呈现按钮.该命令首先执行所以我已经在click中处理了它.这个功能应该适用于Android和iOS.

public class RippleButton : Button
{
    private readonly Color _defaultBackgroundColor = Color.FromRgb(255, 87, 34);
    private readonly Color _clickedBackgroundColor = Color.FromRgb(76, 175, 80);

    public ICommand ClickCommand
    {
        get { return (ICommand)GetValue(ClickCommandProperty); }
        set
        {
            SetValue(ClickCommandProperty, value);
        }
    }


    public static readonly BindableProperty ClickCommandProperty = BindableProperty.Create(
                                                   propertyName: nameof(ClickCommand),
                                                   returnType: typeof(ICommand),
                                                   declaringType: typeof(RippleButton),
                                                   defaultValue: null,
                                                   defaultBindingMode: BindingMode.TwoWay,
                                                   propertyChanged: OnClickCommandChanged);

    private static void OnClickCommandChanged(BindableObject bindable, object oldvalue, object newvalue)
    {
    }

    public RippleButton()
    {
        const int animationTime = 10;


        TextColor = Color.FromRgb(255, 255, …
Run Code Online (Sandbox Code Playgroud)

c# mvvm xamarin xamarin.forms

3
推荐指数
1
解决办法
4832
查看次数

标签 统计

c# ×1

mvvm ×1

xamarin ×1

xamarin.forms ×1