Exemple #1
0
        /// <summary>
        /// Fired the the object is ready, setup the scroll detection.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EndDetectingListView_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            // Get the scroll bars
            List <DependencyObject> scrollBars = new List <DependencyObject>();

            UiControlHelpers <ScrollBar> .RecursivelyFindElement(this, ref scrollBars);

            // Find the scrollbar we want. Fun fact. Since in the scollviewer (which is in the list) the scrollContentPresenter is before the
            // main scrollbars we will find scrollbars of the header before ours. Ours should always be the last scrollbars in the list.
            // SO KEEP GOING DON'T BREAK until we find the last vertical scrollbar.
            foreach (DependencyObject dObject in scrollBars)
            {
                if (((ScrollBar)dObject).Orientation == Orientation.Vertical)
                {
                    m_listeningScrollBar = (ScrollBar)dObject;
                }
            }

            // Make sure we found it
            if (m_listeningScrollBar == null)
            {
                throw new Exception("Failed to find the scroll bar!");
            }

            // Add the listener
            m_listeningScrollBar.ValueChanged += ScrollBar_ValueChanged;
        }
        private void SimpleTextButton_Loaded(object sender, RoutedEventArgs e)
        {
            // Unregister for loaded events so we don't do this many times.
            Loaded -= SimpleTextButton_Loaded;

            // First, try to get the main root grid.
            var uiElements = new List <DependencyObject>();

            UiControlHelpers <Grid> .RecursivelyFindElement(this, ref uiElements);

            if (uiElements.Count != 1)
            {
                throw new Exception("Found too many or too few grids!");
            }

            // Grab it
            _uiContentRoot = (Grid)uiElements[0];

            // Next try to find the text block
            uiElements.Clear();
            UiControlHelpers <TextBlock> .RecursivelyFindElement(this, ref uiElements);

            if (uiElements.Count != 1)
            {
                throw new Exception("Found too many or too few textblocks!");
            }

            // Grab it
            _uiButtonText = (TextBlock)uiElements[0];

            // If the desired text already exists set it
            if (_mCurrentButtonText != null)
            {
                _uiButtonText.Text = _mCurrentButtonText;
            }

            // Set the normal text color
            _uiButtonText.Foreground = new SolidColorBrush(_mNormalTextColor);

            // Grab the current accent color
            _mAccentColor = ((SolidColorBrush)Application.Current.Resources["SystemControlBackgroundAccentBrush"]).Color;

            // Next create our storyboards and animations
            _mColorStoryboard = new Storyboard();
            _mColorAnimation  = new ColorAnimation();
            _mColorStoryboard.Children.Add(_mColorAnimation);

            // Set them up.
            Storyboard.SetTarget(_mColorStoryboard, _uiButtonText);
            Storyboard.SetTargetProperty(_mColorStoryboard, "(TextBlock.Foreground).(SolidColorBrush.Color)");
            _mAnimateInDuration  = new Duration(new TimeSpan(0, 0, 0, 0, 200));
            _mAnimateOutDuration = new Duration(new TimeSpan(0, 0, 0, 0, 400));

            // Last add our events to the grid
            _uiContentRoot.PointerPressed  += ContentRoot_PointerPressed;
            _uiContentRoot.Tapped          += ContentRoot_Tapped;
            _uiContentRoot.PointerCanceled += ContentRoot_PointerCanceled;
            _uiContentRoot.PointerExited   += ContentRoot_PointerExited;
            _uiContentRoot.PointerReleased += ContentRoot_PointerReleased;
        }