This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I've got a DateTime property that I want the users to be able to edit both the Date and Time of, so I've pointed the respective controls at this property.
<ms:TimePicker x:Name="FillTime" SelectedTime="{Binding FillDate, Mode=TwoWay}" TimeDisplayMode="TwelveHourTime" Grid.Row="1" Grid.Column="0" Margin="12,0,0,0" /> <ms:DatePicker x:Name="FillDate" SelectedDate="{Binding FillDate, Mode=TwoWay}" DateFormat="dd MMM yyyy" Grid.Row="1" Grid.Column="1" Margin="0,0,12,0"/> Unfortunately only the DatePicker saves changes back. Is this becuase it gets parsed second and overrides the Binding of the TimePicker? At this stage my work around is to provide a second property to access the time which points at the same underlying field. This feels kind of clunky. Are there any other approaches? |
|
|
Hello Your work around is an appropriate way of doing this. Generally if you have 2 or more controls binding to a single property, using one of the controls will change the property value and update the other controls display value. But in the case of a DateTime property, this is not the behaviour you want. Each control is only updating part of the overall property value. So in this scenario it make sense to split the value into two properties so that each control has its own property to bind to. You will also notice that the TimePicker controls' SelectedTime property is of type TimeOfDay so it's not compatible with a DateTime property. Let us know if your work around is still not desired. |
|