DataBinding IsChecked on a checkbox with a nullable bool (ThreeState)
Hey!
I've been trying to databind the IsChecked value on a checkbox using a Nullable<bool>, but no matter which approach I take to set the indeterminate/null value, it seems to switch to false. Setting {x:Null} straight in the xaml does seem to work.
As far as I can tell, there is no way to directly use a Nullable<bool> in NsProp, so a boxing method would be required. I tried these variants, but the all end up as false in the xaml:
So yeah, I'm a bit lost on how to properly implement this.
I've been trying to databind the IsChecked value on a checkbox using a Nullable<bool>, but no matter which approach I take to set the indeterminate/null value, it seems to switch to false. Setting {x:Null} straight in the xaml does seem to work.
As far as I can tell, there is no way to directly use a Nullable<bool> in NsProp, so a boxing method would be required. I tried these variants, but the all end up as false in the xaml:
Code: Select all
Noesis::BaseComponent* TUIOverviewMapHUDVM::GetAllFiltersEnabled1() const
{
return Noesis::Boxing::Box<Noesis::Nullable<bool>>(Noesis::Nullable<bool>());
}
Noesis::BaseComponent* TUIOverviewMapHUDVM::GetAllFiltersEnabled2() const
{
return Noesis::Boxing::Box<Noesis::Nullable<bool>>(nullptr);
}
Noesis::BaseComponent* TUIOverviewMapHUDVM::GetAllFiltersEnabled3() const
{
return nullptr;
}-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: DataBinding IsChecked on a checkbox with a nullable bool (ThreeState)
Hello, exposing a Nullable<bool> property is working fine like this:
You can set the _value just assigning nullptr or true/false.
Could you try that?
Code: Select all
const Nullable<bool>& GetValue() const { return _value; }
void SetValue(const Nullable<bool>& v)
{
if (_value != v)
{
_value = v;
OnPropertyChanged("Value");
}
}
...
NsProp("Value", &ViewModel::GetValue, &ViewModel::SetValue)Could you try that?
Re: DataBinding IsChecked on a checkbox with a nullable bool (ThreeState)
Ah yes, that does work. Thanks!
Who is online
Users browsing this forum: Google [Bot] and 3 guests