xaml中的自定义按钮用户控件的绑定颜色

时间:2016-05-31 11:47:47

标签: c# xaml windows-runtime uwp

我创建了一个自定义模板,其中包含动画悬停和单击颜色,模板代码如下所示 http://pastebin.com/6jKYYygD 和我的usercontrol xaml代码如下 http://pastebin.com/2GHxvnmu 和cs代码如下

namespace FrontEnd.Views
{
    public sealed partial class IconButton : UserControl
    {
        public IconButton()
        {
            this.InitializeComponent();
        }

        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(IconButton), null);

        public Symbol Icon
        {
            get { return (Symbol)GetValue(IconProperty); }
            set { SetValue(IconProperty, value); }
        }

        public static readonly DependencyProperty IconProperty =
            DependencyProperty.Register("Icon", typeof(Symbol), typeof(IconButton), null);

        public Brush BackgroundColor
        {
            get { return (Brush)GetValue(BackgroundColorProperty); }
            set { SetValue(BackgroundColorProperty, value); }
        }

        public static readonly DependencyProperty BackgroundColorProperty =
            DependencyProperty.Register("BackgroundColor", typeof(Brush), typeof(IconButton), null);

        public Brush ForegroundColor
        {
            get { return (Brush)GetValue(ForegroundColorProperty); }
            set { SetValue(ForegroundColorProperty, value); }
        }

        public static readonly DependencyProperty ForegroundColorProperty =
            DependencyProperty.Register("ForegroundColor", typeof(Brush), typeof(IconButton), null);


    }
}

当我将BackgroundColor绑定到按钮的background属性时,它显示(Shape.Fill)。(SolidColorBrush.Color)不存在。 提前致谢

0 个答案:

没有答案