Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Multitrigger on a Button doesn't work

$
0
0

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);

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>