Basic Use

Add a reference to CurrencyTextBoxControl.dll from your project, then add the following namespace to your XAML:
Insert the control like this:
<currency:CurrencyTextBox Number="{Binding Number}" />

Data Validation

Data validation should work the same way WPF's TextBox works:
<currency:CurrencyTextBox Number="{Binding Number, ValidatesOnDataErrors=True}">
        <Style TargetType="{x:Type currency:CurrencyTextBox}">
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="FrameworkElement.ToolTip"
                            Value="{Binding RelativeSource={RelativeSource self}, Path=(Validation.Errors).CurrentItem.ErrorContent}" />

Then make sure the class containing the Number property implements IDataErrorInfo
public string Error
    get { throw new System.NotImplementedException(); }

public string this[string columnName]
        if (columnName == "Number" &&
            (_number < 0 || _number > 10))
            "Number must be between zero and ten.";
            return null;

For more details, view the example project included with the source.

Last edited Apr 19, 2012 at 4:08 PM by beoren, version 6


No comments yet.