Binding Noesis::Color with VM
Hello!
I have a ColorPicker UserControl with Noesis::Color DependencyProperty.
I also have a ViewModel inherited from INotifyPropertyChanged. It has a Noesis::Color field that I "register" via NsProp. The getter returns const Noesis::Color&, since otherwise it gave me compilation errors.
I want to bind CurrentColor DependencyProperty with the ViewModel field.
But when I try to bind, I get the error:
What am I doing wrong? Perhaps the problem is that the getter returns a const Noesis::Color& and a converter is needed?
I have a ColorPicker UserControl with Noesis::Color DependencyProperty.
Code: Select all
NS_IMPLEMENT_REFLECTION(ColorPicker, "d.ColorPicker")
{
Noesis::DependencyData* data = NsMeta<Noesis::DependencyData>(Noesis::TypeOf<SelfClass>());
data->RegisterProperty<Noesis::Color>(CurrentColorProperty, "CurrentColor", Noesis::PropertyMetadata::Create(Noesis::Color{}));
}
Code: Select all
const Noesis::Color& SomeVM::GetColor() const
{
return _color;
}
void SomeVM::SetColor(const Noesis::Color& v)
{
if (_color!= v)
{
_color= v;
OnPropertyChanged("Color");
}
}
NS_BEGIN_COLD_REGION
NS_IMPLEMENT_REFLECTION(SomeVM, "d.SomeVM")
{
NsProp("Color", &SomeVM::GetColor, &SomeVM::SetColor);
}
NS_END_COLD_REGION
Code: Select all
<d:ColorPicker CurrentColor="{Binding SomeViewModel.Color, Mode=TwoWay}"/>
Code: Select all
Unable to convert 'Binding SomeViewModel.Color, Mode=TwoWay}' to a valid value for property d.ColorPicker.CurrentColor.
Re: Binding Noesis::Color with VM
Sorry, guys.
Once I made a post, I found a problem that is beyond the scope of the question. :D
Once I made a post, I found a problem that is beyond the scope of the question. :D
Re: Binding Noesis::Color with VM
Great! Thanks for closing this :)
Who is online
Users browsing this forum: No registered users and 47 guests