Open tpitman opened 3 years ago
Hi. After my investigation:
BackgroundColor of StackLayout
is not updated, but Text
of Label
with the same binding updated correctly.
See example below:
<StackLayout Orientation="Vertical" BackgroundColor="{Binding Source={x:Reference LabelColorWheel}, Path=SelectedColor}">
<colorpicker:ColorCircle x:Name="LabelColorWheel" SelectedColor="{Binding LabelColor}"/>
<Label Text="{Binding Source={x:Reference LabelColorWheel}, Path=SelectedColor}"/>
</StackLayout>
This exact case starts working if the binding of ColorCircle is set to OneWayToSource
mode:
<colorpicker:ColorCircle x:Name="LabelColorWheel" SelectedColor="{Binding LabelColor, Mode=OneWayToSource}"/>
Right now, I can't find out is it a ColorPicker problem or not. Hope it will help you.
Thank you. I will try it out and let you know.
hi @vpapenko i tested onewaytosource and it works, however this is not the ideal solution, as if you change the mode to twoway and try to set the color through VM it won't work. if you also try to change the color through the wheel, it won't set the color in the view model either.
@vpapenko would you look into this issue and address it?
Hi @pasha-o
I didn't found root of this problem or any solution after my brief investigations.
Unfortunately, I have no time for now.
So any contribution is welcome.
The only possible solution I can provide now is to use new SelectedColorChanged
event and code-behind.
Binding the selected color doesnt seem to work, but the even handler for value change does
SelectedColor="{Binding SelectedColor, Mode=OneWayToSource}" <!-- works if added mode-->
ShowLuminosityWheel="False"
SelectedColorChanged="OnColorWheelSelect"/> <!--Works-->
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:
Expected behavior I would expect my view model property SET to be called any time the color changes.
Desktop (please complete the following information):
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.