Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 背景色不与属性绑定_C#_Xamarin_Xamarin.forms_Xamarin.android - Fatal编程技术网

C# 背景色不与属性绑定

C# 背景色不与属性绑定,c#,xamarin,xamarin.forms,xamarin.android,C#,Xamarin,Xamarin.forms,Xamarin.android,我无法将背景颜色绑定到位于代码隐藏中的属性 我的财产: public Color SelectedColor { get { return selectedColor; } set { pdfViewerControl.AnnotationSettings.FreeText.TextColor = value; selectedColo

我无法将背景颜色绑定到位于代码隐藏中的属性

我的财产:

public Color SelectedColor
    {
        get
        {
            return selectedColor;
        }

        set
        {
            pdfViewerControl.AnnotationSettings.FreeText.TextColor = value;
            selectedColor = value;
            // Call OnPropertyChanged whenever the property is updated
            OnPropertyChanged();
        }
    }
我的按钮:

Button colorButton = new Button();
        colorButton.CornerRadius = 20;
        colorButton.BorderWidth = 2;
        colorButton.HeightRequest = 30;
        colorButton.WidthRequest = 30;
        colorButton.BindingContext = this;
        colorButton.SetBinding(Button.BorderColorProperty, new Binding("Value", source: SelectedColor));
        colorButton.SetBinding(Button.BackgroundColorProperty, new Binding("BackgroundColor", source: SelectedColor));
我尝试了不同的绑定上下文,但不起作用


代码的两部分在同一页上

如果属性名为
SelectedColor
,则在创建绑定时应将其用作绑定路径

colorButton.SetBinding(Button.BackgroundColorProperty, new Binding("SelectedColor"));

好吧,现在有道理了,我在读这篇文章时误解了这个概念:。非常感谢。