示例#1
0
        private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Expander ep = (Expander)d;

            bool newValue = (bool)e.NewValue;

            // Fire accessibility event
            ExpanderAutomationPeer peer = UIElementAutomationPeer.FromElement(ep) as ExpanderAutomationPeer;

            if (peer != null)
            {
                peer.RaiseExpandCollapseAutomationEvent(!newValue, newValue);
            }

            if (newValue)
            {
                ep.OnExpanded();
            }
            else
            {
                ep.OnCollapsed();
            }

            ep.UpdateVisualState();
        }
        public virtual void ExpanderPeerOnlySupportsExpandCollapse()
        {
            Expander item = new Expander();
            ExpanderAutomationPeer peer = null;

            TestAsync(
                item,
                () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ExpanderAutomationPeer,
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Dock), "ExpanderAutomationPeer should not support the Dock pattern!"),
                () => Assert.IsNotNull(peer.GetPattern(PatternInterface.ExpandCollapse), "ExpanderAutomationPeer should support the ExpandCollapse pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Grid), "ExpanderAutomationPeer should not support the Grid pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.GridItem), "ExpanderAutomationPeer should not support the GridItem pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Invoke), "ExpanderAutomationPeer should not support the Dock pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.MultipleView), "ExpanderAutomationPeer should not support the MultipleView pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.RangeValue), "ExpanderAutomationPeer should not support the RangeValue pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Scroll), "ExpanderAutomationPeer should not support the Scroll pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.ScrollItem), "ExpanderAutomationPeer should not support the ScrollItem pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Selection), "ExpanderAutomationPeer should not support the Selection pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Table), "ExpanderAutomationPeer should not support the Table pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.TableItem), "ExpanderAutomationPeer should not support the TableItem pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Toggle), "ExpanderAutomationPeer should not support the Toggle pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Transform), "ExpanderAutomationPeer should not support the Transform pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Value), "ExpanderAutomationPeer should not support the Value pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Window), "ExpanderAutomationPeer should not support the Window pattern!"));
        }
        public void VerifyExpandAndCollapseWorkCorrectly()
        {
            var presenter    = (UniversalPlatformContractPresenter)ControlsTestPage.Instance.FindName("TestContractPresenter");
            var expander     = (Expander)presenter.FindName("RootExpander");
            var expanderPeer = new ExpanderAutomationPeer(expander);

            Assert.IsNotNull(expander.Header);
            Assert.IsNotNull(expander.Content);
            Assert.AreEqual(expanderPeer.ExpandCollapseState, Windows.UI.Xaml.Automation.ExpandCollapseState.Collapsed);
        }
        public virtual void ExpanderAutomationPeerTypeAndClass()
        {
            Expander item = new Expander();
            ExpanderAutomationPeer peer = null;

            TestAsync(
                item,
                () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ExpanderAutomationPeer,
                () => Assert.AreEqual(AutomationControlType.Group, peer.GetAutomationControlType(), "Unexpected AutomationControlType!"),
                () => Assert.AreEqual("Expander", peer.GetClassName(), "Unexpected ClassType!"));
        }
        public virtual void ExpanderCreatesAutomationPeer()
        {
            Expander item = new Expander();
            ExpanderAutomationPeer peer = null;

            TestAsync(
                item,
                () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ExpanderAutomationPeer,
                () => Assert.IsNotNull(peer, "Expander peer should not be null!"),
                () => Assert.AreEqual(item, peer.Owner, "Expander should be owner of the peer!"));
        }
        public virtual void ExpanderPeerExpandStateCollapsed()
        {
            Expander item = new Expander();
            ExpanderAutomationPeer  peer     = null;
            IExpandCollapseProvider provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ExpanderAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => Assert.AreEqual(ExpandCollapseState.Collapsed, provider.ExpandCollapseState, "Unexpected ExpandCollapseState!"));
        }
        public virtual void ExpanderPeerSupportsExpandCollapse()
        {
            Expander item = new Expander();
            ExpanderAutomationPeer  peer     = null;
            IExpandCollapseProvider provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ExpanderAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => Assert.IsNotNull(provider, "IExpandCollapseProvider peer should not be null!"));
        }
        public virtual void ExpanderPeerCollapseCollapsed()
        {
            Expander item = new Expander();
            ExpanderAutomationPeer  peer     = null;
            IExpandCollapseProvider provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ExpanderAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => provider.Collapse(),
                () => Assert.IsFalse(item.IsExpanded, "Item should be collapsed!"));
        }
        public virtual void ExpanderPeerCollapseDisabled()
        {
            Expander item = new Expander {
                IsEnabled = false
            };
            ExpanderAutomationPeer  peer     = null;
            IExpandCollapseProvider provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ExpanderAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => provider.Collapse());
        }
        // Token: 0x06004B06 RID: 19206 RVA: 0x001524E0 File Offset: 0x001506E0
        private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Expander expander = (Expander)d;
            bool     flag     = (bool)e.NewValue;
            ExpanderAutomationPeer expanderAutomationPeer = UIElementAutomationPeer.FromElement(expander) as ExpanderAutomationPeer;

            if (expanderAutomationPeer != null)
            {
                expanderAutomationPeer.RaiseExpandCollapseAutomationEvent(!flag, flag);
            }
            if (flag)
            {
                expander.OnExpanded();
            }
            else
            {
                expander.OnCollapsed();
            }
            expander.UpdateVisualState();
        }
示例#11
0
        /// <summary>
        /// ExpandedProperty PropertyChangedCallback static function.
        /// </summary>
        /// <param name="d">Expander object whose Expanded property is changed.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs which contains the old and new values.</param>
        private static void OnIsExpandedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Expander ctrl       = (Expander)d;
            bool     isExpanded = (bool)e.NewValue;

            // Notify any automation peers of the expansion change
            ExpanderAutomationPeer peer = FrameworkElementAutomationPeer.FromElement(ctrl) as ExpanderAutomationPeer;

            if (peer != null)
            {
                peer.RaiseExpandCollapseAutomationEvent((bool)e.OldValue, isExpanded);
            }

            if (isExpanded)
            {
                ctrl.OnExpanded();
            }
            else
            {
                ctrl.OnCollapsed();
            }
        }
示例#12
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var expanderControl = new ExpanderAutomationPeer(ExpanderControl);

            expanderControl.Expand();
        }