Reputation: 1
I have this ComleteLocation
method that is like a checkout function.
It works, however I can't seem to format the output. I cant do it in XAML because stringformat is not supported.
I would like the output to screen via XAML binding to be ("HH:mm") because I need to know how long I worked at that customer for instance.
public async void CompleteLocation(Log log)
{
int index = _Log.IndexOf(log);
_Log[index].CheckOut = DateTime.Now;
TimeSpan LoggedTime = log.CheckOut - log.CheckIn;
log.LoggedTime = LoggedTime;
log.NotifyPropertyChanged("CheckOut");
log.NotifyPropertyChanged("LoggedTime");
await saveLogDataAsync();
}
Upvotes: 0
Views: 84
Reputation: 15006
Use your own StringConverter... It comes down to doing:
return String.Format((string)parameter, value);
and using like this
<TextBlock Text="{Binding LoggedTime,
Converter={StaticResource StringFormatConverter},
ConverterParameter='{}{0:HH:mm}'}" />
Upvotes: 2