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

Can I use Triggers from code?

$
0
0

Is there a way how I can use triggers from the code? I can't seem to find any examples. Basically I have some behaviors for my entries, and I want to trigger the Login Button's "IsVisible" property based on the 'IsValid' property from my entry's behavior:

    public class PEntry : Entry
        {
            public PEntry ()
                : base ()
            {
            }

            /// <summary>
            /// Determines whether this instance is valid.
            /// </summary>
            /// <returns><c>true</c> if this instance is valid; otherwise, <c>false</c>.</returns>
            public bool IsValid 
            {
                get{
                    // iterate through each entry's validator behaviors
                    foreach (var behavior in this.Behaviors) {
                        var validatorBehavior = behavior as IValidatorBehavior;
                        if (validatorBehavior != null) {
                            if (!validatorBehavior.IsValid) {
                                return false;
                            }
                        }
                    }

                    // default to true
                    return true;
                }
            }
        }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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