private void OnContactSelected(object sender, ItemClickEventArgs e)
        {
            Contact contact = e.ClickedItem as Contact;

            if (contact != null)
            {
                rootframe.Navigate(typeof(ContactDetailPage), contact);
                VisualStateHelper.SwitchVisualState(this, VisualStateGroup, "state_FrameZero", "state_320");
            }
        }
        private void RootHost_BackRequested(object sender, BackRequestedEventArgs e)
        {
            if (VisualStateHelper.SwitchVisualState(this, VisualStateGroup, "state_320", "state_FrameZero"))
            {
                return;
            }

            if (rootframe.CanGoBack)
            {
                e.Handled = true;
                rootframe.GoBack();
            }
        }
Esempio n. 3
0
 private static void VerifyTabWidthVisualStates(IList <object> items, bool isCompact)
 {
     foreach (var item in items)
     {
         var tabItem = item as TabViewItem;
         if (tabItem.IsSelected || !isCompact)
         {
             VisualStateHelper.ContainsVisualState(tabItem, "StandardWidth");
         }
         else
         {
             VisualStateHelper.ContainsVisualState(tabItem, "Compact");
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Attempts to find a storyboard that matches the newTransition name.
        /// </summary>
        /// <param name="newTransition">The new transition.</param>
        /// <returns>A storyboard or null, if no storyboard was found.</returns>
        private Storyboard GetStoryboard(string newTransition)
        {
            VisualStateGroup presentationGroup = VisualStateHelper.TryGetVisualStateGroup(this, PresentationGroup);
            Storyboard       newStoryboard     = null;

            if (presentationGroup != null)
            {
                newStoryboard = presentationGroup.States
                                .OfType <VisualState>()
                                .Where(state => state.Name == newTransition)
                                .Select(state => state.Storyboard)
                                .FirstOrDefault();
            }
            return(newStoryboard);
        }
Esempio n. 5
0
        void this_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (!isLoaded)
            {
                Tab1_Unselected.Measure(e.NewSize);
                collapsedWidth1 = Tab1_Unselected.DesiredSize.Width;

                Tab2_Unselected.Measure(e.NewSize);
                collapsedWidth2 = Tab2_Unselected.DesiredSize.Width;

                Tab1_Unselected.Visibility = Visibility.Collapsed;
                Tab2_Selected.Visibility   = Visibility.Collapsed;

                isLoaded = true;
            }

            var expandedWidth1 = e.NewSize.Width - collapsedWidth2;
            var expandedWidth2 = e.NewSize.Width - collapsedWidth1;

            var select1Storyboard = VisualStateHelper.FindStoryboard(LayoutRoot, "TabStates", "Select1");
            var expand1           = (DoubleAnimation)select1Storyboard.Children.FirstOrDefault(an => Storyboard.GetTargetName(an) == "Tab1" && Storyboard.GetTargetProperty(an).Path == "Width");

            expand1.To = expandedWidth1;
            var collapse2 = (DoubleAnimation)select1Storyboard.Children.FirstOrDefault(an => Storyboard.GetTargetName(an) == "Tab2" && Storyboard.GetTargetProperty(an).Path == "Width");

            collapse2.To = collapsedWidth2;

            var select2Storyboard = VisualStateHelper.FindStoryboard(LayoutRoot, "TabStates", "Select2");
            var expand2           = (DoubleAnimation)select2Storyboard.Children.FirstOrDefault(an => Storyboard.GetTargetName(an) == "Tab2" && Storyboard.GetTargetProperty(an).Path == "Width");

            expand2.To = expandedWidth2;
            var collapse1 = (DoubleAnimation)select2Storyboard.Children.FirstOrDefault(an => Storyboard.GetTargetName(an) == "Tab1" && Storyboard.GetTargetProperty(an).Path == "Width");

            collapse1.To = collapsedWidth1;

            Tab1_Selected.Width = expandedWidth1;
            Tab2_Selected.Width = expandedWidth2;

            if (selectedTab == 1)
            {
                Tab1.Width = expandedWidth1;
            }
            else if (selectedTab == 2)
            {
                Tab2.Width = expandedWidth2;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// TransitionProperty property changed handler.
        /// </summary>
        /// <param name="d">TransitioningContentControl that changed its Transition.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnTransitionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TransitioningContentControl source = (TransitioningContentControl)d;
            string oldTransition = e.OldValue as string;
            string newTransition = e.NewValue as string;

            if (source.IsTransitioning)
            {
                source.AbortTransition();
            }

            // find new transition
            Storyboard newStoryboard = source.GetStoryboard(newTransition);

            // unable to find the transition.
            if (newStoryboard == null)
            {
                // could be during initialization of xaml that presentationgroups was not yet defined
                if (VisualStateHelper.TryGetVisualStateGroup(source, PresentationGroup) == null)
                {
                    // will delay check
                    source.CurrentTransition = null;
                }
                else
                {
                    // revert to old value
                    source.SetValue(TransitionProperty, oldTransition);

                    throw new ArgumentException(
                              "TransitioningContentControl_TransitionNotFound");
                }
            }
            else
            {
                source.CurrentTransition = newStoryboard;
            }
        }
 private void BtnAddContact_Click(object sender, RoutedEventArgs e)
 {
     VisualStateHelper.SwitchVisualState(this, VisualStateGroup, "state_FrameZero", "state_320");
     rootframe.Navigate(typeof(AddContactPage));
 }