Hey maybe someone can explain to me why this code is not working. When the conditions are met the Button
doesn't get enabled. Or do the conditions don't work like that. I mean !string.IsNullOrEmpty
should work right?
var sendButton = new Button
{
HorizontalOptions = LayoutOptions.Fill,
Text = "Absenden",
IsEnabled = false
};
sendButton.Clicked += SendButtonOnClicked;
var enableSetter = new Setter
{
Property = Button.IsEnabledProperty,
Value = true
};
var enableButtonTrigger = new MultiTrigger(typeof (Button))
{
Conditions =
{
new BindingCondition
{
Binding = new Binding(Entry.TextProperty.PropertyName, source: _buModel.NameEntry),
Value = !string.IsNullOrEmpty(_buModel.NameEntry.Text)
},
new BindingCondition
{
Binding = new Binding(Entry.TextProperty.PropertyName, source: _buModel.JobEntry),
Value = !string.IsNullOrEmpty(_buModel.JobEntry.Text)
},
new BindingCondition
{
Binding = new Binding(NumericEntry.TextProperty.PropertyName, source: _buModel.MonthlyWageEntry),
Value = !string.IsNullOrEmpty(_buModel.MonthlyWageEntry.Text)
}
},
Setters = { enableSetter }
};
sendButton.Triggers.Add(enableButtonTrigger);