DataBinding IsChecked on a checkbox with a nullable bool (ThreeState)
Posted: 22 May 2024, 13:24
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;
}