I want to add masking to WPF date picker control. I saw that DatePickerTextBox can not be extended any further.
So, I decided a add a interactivity behavior to it. I used following code for this:
Masked date picker class:
public class MaskedDatePicker : DatePicker { }
and I created a attached behavior like below:
public class DatePickerTextBoxInputMaskBehavior : Behavior<DatePickerTextBox> { }
Now in templates I attached the behavior:
<DatePickerTextBox x:Name="PART_TextBox" Grid.Row="0" Grid.Column="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Focusable="{TemplateBinding Focusable}" Foreground="{TemplateBinding Foreground}"><i:Interaction.Behaviors><cleanPoc:DatePickerTextBoxInputMaskBehavior /></i:Interaction.Behaviors></DatePickerTextBox>
Now every time i open the calender from datepicker application freezes because text changed in DatePickerTextBoxInputMaskBehavior got fired recursively.
Kindly suggest Where is the issue and How can i add masking to a date picker. I have attached the code for the sample application. Complete code can be found here: https://onedrive.live.com/?cid=1031D83C0E173CE9&id=1031D83C0E173CE9%21105
Please help