I\'m developing a custom text box for currency editing.
I\'ve seen some ready to use ones, but they\'re complicated and/or not really usable, forcing you to bad practi
create new Dependency Property
like this
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register(
"Value",
typeof(decimal?),
typeof(CurrencyTextBox),
new FrameworkPropertyMetadata(
new decimal?(),
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
new PropertyChangedCallback(ValuePropertyChanged)));
private static void ValuePropertyChanged(
DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
CurrencyTextBox x = (CurrencyTextBox)d;
x.Value = (decimal?)e.NewValue;
}
and then bind to this new property