
Hi,
I'm implementing a Timer app in .Net 4.0. The user will set a start and a stop time/date in which certain processes will happen.
The app has a Repeat timer every X periode and depending on that I need to change the UI of the timer.
My problem is when iI have Repeat everyday between TimeX and TimeY I don't know how to bind the value chosen moade TwoWay.
Have in mind that the whole ap needs to be pure MVVM and no code behind.
.cs ViewModel code:
public TimeSpan SelectedTime
{
get
{
string t = Time.Value.ToString().PadLeft(6, '0');
string tstr = string.Format("{0}{1}:{2}{3}:{4}{5}", t[0], t[1], t[2], t[3], t[4], t[5]);
try
{
TimeSpan.TryParseExact(tstr, "g", CultureInfo.InvariantCulture, out _selectedTime);
}
catch (Exception)
{
_selectedTime = DateTime.Now.TimeOfDay;
}
return _selectedTime;
}
set
{
string time = value.ToString("hhmmss");
long timeToLong;
long.TryParse(time, out timeToLong);
Time.Value = new PValue(timeToLong, 0);
RaisePropertyChanged(() => SelectedTime);
}
}
.xaml View code:
<editors:DateTimeEditBox Name="TPicker" Grid.Row="3" Width="100" HorizontalAlignment="Left" AllowDrop="False"
Format="{Binding Path=TimeFormat}" Margin="5" ToolTip="{Binding Path=TimeFormat}"
DropDownButtonVisibility="Collapsed" VerticalAlignment="Center" DateValue="{Binding Path=SelectedTime, Mode=TwoWay}"
DropDownButtonInactiveVisibility="Collapsed" SpinnerVisibility="Visible">
</editors:DateTimeEditBox>
The time that I obtain in the SelectedTime property is smth like: "12:34:56" but in the UI nothing is loaded.
Could you please help me with this? BTW I'm new at using Actipro and wpf in general.
Best regards,
Zee.