I create some buttons in the CS code behind of my xaml in a loop. Since those buttons work together I have create a Dynamic Resource for enable and disable them
Resources = new ResourceDictionary
{
{"frequencyButtonsEnabled", true }
};
and after my loop I create the binding
frequencyResponseButton.SetDynamicResource(IsEnabledProperty, "frequencyButtonsEnabled");
It works in the manner that when I do Resources["frequencyButtonsEnabled"] = true;
all the buttons are enabled, but the problem is that their background color gets reset, so instead of the Color.Aqua
value that I use, their color is the default one.
I tried to add a resource with the color
Resources = new ResourceDictionary
{
{"frequencyButtonsEnabled", true },
{"backgroundButtonsColor", Color.Aqua }
};
binding it
frequencyResponseButton.SetDynamicResource(IsEnabledProperty, "frequencyButtonsEnabled");
frequencyResponseButton.SetDynamicResource(BackgroundColorProperty, "backgroundButtonsColor");
and recall it after enable my buttons,
Resources["frequencyButtonsEnabled"] = true;
Resources["backgroundButtonsColor"] = Color.Aqua;
But it is still the default color. Does anybody knows why this happens and/or how to fix it?
Thanks
Edit to add some images and clarify that it works ok on Android
This is the button without setting the IsEnabled
to false
:
This is how it looks when is disabled:
And this how it looks after get enabled by an event: