Пример #1
0
        private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            NameValueControl control  = d as NameValueControl;
            object           newValue = e.NewValue;

            if (control != null && newValue != null)
            {
                if (newValue is string)
                {
                    control.valueTextBlock.Text = newValue as string;
                }
                else if (newValue is double)
                {
                    if (control.RoundFloatingPointNumbers)
                    {
                        control.valueTextBlock.Text = Math.Round((double)newValue, 1).ToString();
                    }
                    else
                    {
                        control.valueTextBlock.Text = newValue.ToString();
                    }
                }
                else if (newValue is bool)
                {
                    control.valueTextBlock.Text = (bool)newValue ? "Yes" : "No";
                }
                else
                {
                    control.valueTextBlock.Text = newValue.ToString();
                }
            }
        }
Пример #2
0
        private static void OnNamePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            NameValueControl control = d as NameValueControl;

            if (control != null)
            {
                string newValue = e.NewValue as string;
                control.nameTextBlock.Text = newValue as string;
            }
        }