private static object CoerceValue(DependencyObject element, object baseValue) { NumericUpDownInt control = (NumericUpDownInt)element; int value = (int)baseValue; control.CoerceValueToBounds(ref value); // Get the text representation of Value string valueString = value.ToString(control.m_culture); if (control.IsThousandSeparatorVisible) { if (control.m_text_box != null) { control.m_text_box.Text = value.ToString("N", control.m_culture); } } else { if (control.m_text_box != null) { control.m_text_box.Text = value.ToString(); } } return(baseValue); }