Changing Visual state of an Entry inside a collection view

Manickam, Suraj 320 Reputation points

I have a Collection view with entries , based on certain conditions , I will have to change the visual state to either disabled or normal . I have already defined them in styles.xaml. I tried it by binding isEnabled property of Entry but the background color of entry does not change according to the ones defined in the Visual state. How do I get this working?

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,179 questions
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 71,836 Reputation points Microsoft Vendor

    Do you implement this INotifyPropertyChanged in your Model like following code? After that, your isenabled property will be changed at the runtime.

    public class Monkey: INotifyPropertyChanged
         public event PropertyChangedEventHandler PropertyChanged;
         public void OnPropertyChanged([CallerMemberName] string name = "") =>
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
         private bool _isEnabled;
         public bool IsEnabled
             get => _isEnabled;
                 if (_isEnabled != value)
                     _isEnabled = value;
                     OnPropertyChanged(); // reports this property
             IsEnabled="{Binding IsEnabled}"

0 additional answers

Sort by: Most helpful