Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF Date picker selected date does not get reset after deleting date

$
0
0

I  have extended WPF default datepicker control and created a custom date picker with masking in the date picker text box.

For this I overridded the template for datepicker text box like below:

<Style x:Key="DatePickerTextBoxStyle" TargetType="{x:Type DatePickerTextBox}"><Setter Property="Height" Value="20" /><Setter Property="Control.Template"><Setter.Value><ControlTemplate><TextBox x:Name="PART_TextBox"
                             Style="{DynamicResource CalendarTextBoxStyle}"
                             TabIndex="0"
                             Text="{Binding Path=SelectedDate,
                                            Mode=TwoWay,
                                            StringFormat='d',
                                            ConverterCulture={x:Static glob:CultureInfo.CurrentCulture},
                                            RelativeSource={RelativeSource AncestorType={x:Type maskedDatePickerLib:MaskedDatePicker}}}"
                             TextWrapping="Wrap"><i:Interaction.Behaviors><maskedDatePickerLib:TextBoxInputMaskBehavior InputMask="00/00/0000" PromptChar="_" /></i:Interaction.Behaviors></TextBox></ControlTemplate></Setter.Value></Setter></Style>

I have created a interactivity behavior (for masking) and attached to a text box and put it in a date picker text box template. 

Now the problem is when I select a date from date picker calender and delete it from text box manually. Then if I again try to select the same date it does not appear in textbox.

When I used Snoop in the application I saw that even after deleting the text from text box. SelectedDate property of date picker still have the date. Kindly suggest. 

 


Viewing all articles
Browse latest Browse all 18858

Trending Articles