Exemplo n.º 1
0
        /// <summary>
        /// Tries to match the selector with a control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns>A <see cref="SelectorMatch"/>.</returns>
        public SelectorMatch Match(IStyleable control)
        {
            List <IObservable <bool> > inputs = new List <IObservable <bool> >();
            Selector selector = this;

            while (selector != null)
            {
                if (selector._inTemplate && control.TemplatedParent == null)
                {
                    return(SelectorMatch.False);
                }

                var match = selector._evaluate(control);

                if (match.ImmediateResult == false)
                {
                    return(match);
                }
                else if (match.ObservableResult != null)
                {
                    inputs.Add(match.ObservableResult);
                }

                selector = selector.MovePrevious();
            }

            if (inputs.Count > 0)
            {
                return(new SelectorMatch(new StyleActivator(inputs)));
            }
            else
            {
                return(SelectorMatch.True);
            }
        }
Exemplo n.º 2
0
        public StyleActivator GetActivator(IStyleable control)
        {
            List <IObservable <bool> > inputs = new List <IObservable <bool> >();
            Selector selector = this;

            while (selector != null)
            {
                if (selector.InTemplate && control.TemplatedParent == null)
                {
                    inputs.Add(Observable.Return(false));
                }
                else
                {
                    inputs.Add(selector.GetObservable(control));
                }

                selector = selector.MovePrevious();
            }

            return(new StyleActivator(inputs));
        }