Dany
Dany

Reputation: 2174

ReadOnly DatePicker in silverlight

I am making an application in Silverlight 3.0. In that application i am using DatePicker control as

<TextBlock FontSize="13" Height="23" Name="txtFromDate" Text="FromDate" Width="40" Canvas.Left="444" Canvas.Top="6" />
<controls:DatePicker Name="fromdatePicker" Height="23" Width="110" Canvas.Left="550" Canvas.Top="4"  />

Here i don't want to enter date manually(Means the textblock txtFromDate should be read only.)And the value in text block will be whatever date is selected from calender. I am not getting how to do it? Please help me.Thanks in advance.

Upvotes: 0

Views: 569

Answers (1)

ken2k
ken2k

Reputation: 48975

Assuming you're using a nice MVVM approach:

Bind the SeletectedDate of your date picker to a DateTime property of your ViewModel (two-way binding):

<sdk:DatePicker SelectedDate="{Binding MyDate, Mode=TwoWay}"/>

Bind the Text property of your TextBlock to the same property:

<TextBlock Text="{Binding MyDate}" />

Upvotes: 1

Related Questions