Hi,
TextBox is supposed to show masked dollar amount for certain access privileges. I created a converter class(inheriting from IValueConverter) to handle masking by implementing the convert method.
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
The third parameter is passed true if masking is needed else false.
Called like this:
CurrencyCOnverter converter = new CurrencyConverter();
this._textbox1.Text = converter.Convert(Amount, typeof(string), !this.IsSuperUser,
CurrentCulture).ToString();
I have about 12 textboxes on UI. Instead of doing this at 12 places, I defined DataTemplates in Resource dictionary which looks like this:
<DataTemplate x:Key="MaskNormalBackgroundTbx">
<TextBlock TextAlignment="Right" VerticalAlignment="Center"
TextWrapping="WrapWithOverflow"
Text="{Binding "Amount"
Converter={StaticResource CurrencyDisplayConverter},
ConverterParameter=true}" />
</DataTemplate>
<DataTemplate x:Key="NoMaskNormalBackgroundTbx">
<TextBlock TextAlignment="Right" VerticalAlignment="Center"
TextWrapping="WrapWithOverflow"
Text="{Binding "Amount"
Converter={StaticResource CurrencyDisplayConverter},
ConverterParameter=false}" />
</DataTemplate>
My Question: Is there a way I can assign this template to textbox by creating a custom textbox just like we assign data templates for ListBox?
Thanks,
Megan.