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

output to the SelectedDate property of a databound datepicker wpf

$
0
0

I had the datepicker to have its selected date property bound to the dataset as shown in the XAML below:

<DatePicker x:Name="date_picker" Margin="0,0,0.2,0" SelectedDate="{Binding Date, Mode=TwoWay, 
NotifyOnValidationError=true, ValidatesOnExceptions=true, StringFormat=dd-MM-yyyy}" ToolTip="Please
select a date" FirstDayOfWeek="Monday" SelectedDateFormat="Short" DisplayDateStart="2013-01-01" 
DisplayDateEnd="2020-01-01" />

But when the window loads, I wanted the default output to be today's date instead of the default"Select a date", but when I use the code below, i just get the default "select a date". I think it may be because SelectedDate property is used twice. How would i fix this problem?

date_picker.SelectedDate = DateTime.Today; 


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>