Я не могу привязать цвет фона к своей собственности, расположенной в моем коде позади.
Моя собственность:
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));
Я пробовал другой обязательный контекст, но он не работает.
Оба раздела кода находятся на одной странице.