Exemplo n.º 1
0
        /// <summary>
        /// Handle the Value of MoneyBox changing. Change the value of Text to match.
        /// </summary>
        /// <param name="sender">The MoneyBox.</param>
        /// <param name="eventArgs">The event arguments.</param>
        static private void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
        {
            MoneyBox box = sender as MoneyBox;

            box.Text        = String.Format("{0:0.00}", box.Value);
            box.DisplayText = String.Format("{0:C}", box.Value);

            box.RaiseEvent(new RoutedEventArgs(MoneyBox.ValueChangedEvent));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handle the value of IsNullable changing. Try to set a reasonable value for Value if it doesn't have one.
        /// </summary>
        /// <param name="sender">The MoneyBox.</param>
        /// <param name="eventArgs">The event arguments.</param>
        private static void OnIsNullableChanged(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
        {
            MoneyBox box = sender as MoneyBox;

            if (!box.IsNullable && box.Value == null)
            {
                box.Value = box.oldValue;
            }
        }