I have written code to attach a property Mask.But iam getting the error
Cannot resolve the Style Property 'Marsk'. Verify that the owning type is the Style's TargetType, or use Class.Property syntax to specify the Property.)
public static MaskType GetMask(DependencyObject obj)
{
return (MaskType)obj.GetValue(MaskProperty);
}
public static void SetMask(DependencyObject obj, MaskType value)
{
obj.SetValue(MaskProperty, value);
}
public static readonly DependencyProperty MaskProperty =
DependencyProperty.RegisterAttached(
"Mask",
typeof(MaskType),
typeof(pMaskableTextBox),
new FrameworkPropertyMetadata(MaskChangedCallback)
);
private static void MaskChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (e.OldValue is TextBox)
{
(e.OldValue as TextBox).PreviewTextInput -= TextBox_PreviewTextInput;
DataObject.RemovePastingHandler((e.OldValue as TextBox), (DataObjectPastingEventHandler)TextBoxPastingEventHandler);
}
TextBox _this = (d as TextBox);
if (_this == null)
return;
if ((MaskType)e.NewValue != MaskType.Any)
{
_this.PreviewTextInput += TextBox_PreviewTextInput;
DataObject.AddPastingHandler(_this, (DataObjectPastingEventHandler)TextBoxPastingEventHandler);
}
ValidateTextBox(_this);
}
i have called this property in styles rStyles.XAML
xmlns:pBasePage="clr-namespace:Parts.Pages.Page;assembly=Parts.Pages.Page"
<Style x:Key="styDecimalTextBox" TargetType="{x:Type TextBox}">
<Setter Property="pBasePage:Parts.Pages.Page.pMaskableTextBox.Mask" Value ="Decimal" />
</Style>
Cannot resolve the Style Property 'Marsk'. Verify that the owning type is the Style's TargetType, or use Class.Property syntax to specify the Property.)
public static MaskType GetMask(DependencyObject obj)
{
return (MaskType)obj.GetValue(MaskProperty);
}
public static void SetMask(DependencyObject obj, MaskType value)
{
obj.SetValue(MaskProperty, value);
}
public static readonly DependencyProperty MaskProperty =
DependencyProperty.RegisterAttached(
"Mask",
typeof(MaskType),
typeof(pMaskableTextBox),
new FrameworkPropertyMetadata(MaskChangedCallback)
);
private static void MaskChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (e.OldValue is TextBox)
{
(e.OldValue as TextBox).PreviewTextInput -= TextBox_PreviewTextInput;
DataObject.RemovePastingHandler((e.OldValue as TextBox), (DataObjectPastingEventHandler)TextBoxPastingEventHandler);
}
TextBox _this = (d as TextBox);
if (_this == null)
return;
if ((MaskType)e.NewValue != MaskType.Any)
{
_this.PreviewTextInput += TextBox_PreviewTextInput;
DataObject.AddPastingHandler(_this, (DataObjectPastingEventHandler)TextBoxPastingEventHandler);
}
ValidateTextBox(_this);
}
i have called this property in styles rStyles.XAML
xmlns:pBasePage="clr-namespace:Parts.Pages.Page;assembly=Parts.Pages.Page"
<Style x:Key="styDecimalTextBox" TargetType="{x:Type TextBox}">
<Setter Property="pBasePage:Parts.Pages.Page.pMaskableTextBox.Mask" Value ="Decimal" />
</Style>