It's my first time using Triggers and I'm going round in circles on this one...
How do I disable a button using a DataTrigger when the length of my ActivityType field in the underlying view model is zero?
Using the code below the button never becomes disabled even though the ActivityField is empty.
_saveButton = new Button
Text = "Save Activity",
BackgroundColor = Helpers.Color.PrimaryColor.ToFormsColor(),
TextColor = Helpers.Color.TextIcons.ToFormsColor(),
Margin = 10,
Binding binding = new Binding(); binding.Source = ViewModel.ActivityType; binding.Path = ViewModel.ActivityType.Length.ToString(); DataTrigger trigger = new DataTrigger(typeof(Button)); trigger.Binding = binding; trigger.Value = 0; Setter s = new Setter(); s.Property = IsEnabledProperty; s.Value = false; trigger.Setters.Add(s); _saveButton.Triggers.Add(trigger);