-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Describe the bug
When I try to bind the SelectedColor to a ViewModel class it gets the value, but won't set it
To Reproduce
Steps to reproduce the behavior:
- Create a project and get ColorPicker all set up according to instructions
- Add using Xamarin.Forms ViewModel binding by using the BindingContext in the xaml
- Add a property to the ViewModel of type Xamarin.Forms.Color with a get and set
- Add a ColorPicker to the xaml and use standard binding format to bind it to the view model property
- Run the project and change the color on the color wheel
Expected behavior
I would expect my view model property SET to be called any time the color changes.
Desktop (please complete the following information):
- OS: iOS
- Version: Latest
Additional context
If I change my xaml to be similar to the TestApp project so that another control in the xaml uses a reference binding then it work, but only if I remove my binding to my view model property. If they are both there, then neither one updates.
Note that when I have my view model binding in place and I set a break point in the GET of my property it does hit it and retrieves the color just fine.
Here is my xaml:
<StackLayout Orientation="Vertical" BackgroundColor="{Binding Source={x:Reference LabelColorWheel}, Path=SelectedColor}">
<colorpicker:ColorCircle x:Name="LabelColorWheel" SelectedColor="{Binding LabelColor}"/>
</StackLayout>
Here is my view model:
private Color _labelColor;
public Color LabelColor
{
get { return _labelColor; }
set
{
if (_labelColor != value)
{
_labelColor = value;
SafePropertyChanged("LabelColor");
}
}
}
I am sorry my formatting isn't very good. It doesn't seem to paste code like I expect.