Ejemplo n.º 1
0
        public void Detach()
        {
            var visualGroup = VisualStateUtilities.GetVisualStateGroups(StatefulElement).First(group => group.Name == Group);

            visualGroup.CurrentStateChanged -= OnVisualStateChanged;
            AssociatedObject = null;
        }
Ejemplo n.º 2
0
        public void Attach(DependencyObject associatedObject)
        {
            StatefulElement = (FrameworkElement)associatedObject;
            var visualGroup = VisualStateUtilities.GetVisualStateGroups(StatefulElement).First(group => group.Name == Group);

            visualGroup.CurrentStateChanged += OnVisualStateChanged;
        }
        public void GetVisualStateGroups_UserControlControlWithChildStates_ReturnsChildStates()
        {
            Grid        stateGrid   = VisualStateHelper.CreateObjectWithStates <Grid>();
            UserControl userControl = CreateUserControlWithContent(stateGrid);

            using (new StubWindow(userControl))
            {
                IList vsgs = VisualStateUtilities.GetVisualStateGroups(userControl);
                Assert.AreEqual(vsgs.Count, 1, "Should find 1 VisualStateGroup on the UserControl");
            }
        }
Ejemplo n.º 4
0
 private void HookUptoCompletedEvent(FrameworkElement stateTarget, string stateName)
 {
     if (VisualStateChangedCommand != null)
     {
         _visualStateGroupOfTheStateName = VisualStateUtilities.GetVisualStateGroups(stateTarget)
                                           .OfType <VisualStateGroup>()
                                           .FirstOrDefault(vsg => vsg.States.OfType <VisualState>().Any(vs => vs.Name == stateName));
         if (_visualStateGroupOfTheStateName != null)
         {
             _visualStateGroupOfTheStateName.CurrentStateChanged += OnVisualStateGroupCurrentStateChanged;
         }
     }
 }