예제 #1
0
        /// <summary>
        /// Translates the HorizontalContentAlignment value into a TextAlignment value.
        /// </summary>
        /// <param name="dependencyObject">The Dependency Property that has changed.</param>
        /// <param name="dependencyPropertyChangedEventArgs">The event arguments describing the property change.</param>
        public static void OnHorizontalContentAlignmentChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            // The basic idea here is to translate the HorizontalContentAlignment used by the Control class into a TextAlignment value that is usable by the
            // TextBlock class.  This allows a Control to host a TextBlock with a consistent approach to how the alignment of the content is specified.
            OrderTypeBlock      orderTypeBlock      = (OrderTypeBlock)dependencyObject;
            HorizontalAlignment horizontalAlignment = (HorizontalAlignment)dependencyPropertyChangedEventArgs.NewValue;

            // Translate the HorizontalContentAlignment into a TextAlignment that TextBlocks can use.
            switch (horizontalAlignment)
            {
            case HorizontalAlignment.Center:

                orderTypeBlock.SetValue(OrderTypeBlock.TextAlignmentProperty, TextAlignment.Center);
                break;

            case HorizontalAlignment.Left:

                orderTypeBlock.SetValue(OrderTypeBlock.TextAlignmentProperty, TextAlignment.Left);
                break;

            case HorizontalAlignment.Right:

                orderTypeBlock.SetValue(OrderTypeBlock.TextAlignmentProperty, TextAlignment.Right);
                break;
            }
        }
예제 #2
0
        /// <summary>
        /// Handles a change to the LimitPrice property
        /// </summary>
        /// <param name="dependencyObject">The Dependency Property that has changed.</param>
        /// <param name="dependencyPropertyChangedEventArgs">The event arguments describing the property change.</param>
        private static void OnContentChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            InputHelper.IsPropertyUpdate = true;
            OrderTypeBlock orderTypeBlock = dependencyObject as OrderTypeBlock;

            orderTypeBlock.Format();
            InputHelper.IsPropertyUpdate = false;
        }