Overview:
I've added a time span control to a xaml page, the binding is set via a TimeSpan property in the related View Model. All is working fine bar the default display value on the time picker.
When I test the app, the time picker's value defaults to a high value for example 12:36. I'm aiming to set the value to 00:00 as default.
In order to set the default value I stepped down through the controls properties but don't see any property that can set the default time.
I'm thinking that the 2 way binding should mean my property value could set this value.
Question:
How can I set the time picker display vlaue to default to 00:00 time span?
Time Picker xaml markup:
<TimePicker Grid.Row="2"
Grid.Column="1"
Width="270"
Height="100"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Header="Parking Duration:"
Time="{Binding SelectedParkDuration,
Mode=TwoWay}" />
Binding property:
private TimeSpan? _selectedParkDuration;
public TimeSpan? SelectedParkDuration
{
get
{
return this._selectedParkDuration;
}
set
{
if (_selectedParkDuration != value)
{
_selectedParkDuration = value;
isValidTagRequest = true;
RaisePropertyChanged("SelectedParkDuration");
}
}
}
try this:
private TimeSpan? _selectedParkDuration = new TimeSpan();
or :
private TimeSpan? _selectedParkDuration = TimeSpan.Parse("00:00")