[英]WinPhone 8.1 TimeSpan formatting output
I have this ComleteLocation
method that is like a checkout function. 我有一个类似于Checkout函数的ComleteLocation
方法。
It works, however I can't seem to format the output. 它有效,但是我似乎无法格式化输出。 I cant do it in XAML because stringformat is not supported. 我无法在XAML中执行此操作,因为不支持stringformat。
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. 我希望通过XAML绑定显示的输出为(“ HH:mm”),因为我需要知道例如在该客户工作了多长时间。
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();
}
Use your own StringConverter... It comes down to doing: 使用您自己的StringConverter ...归结为:
return String.Format((string)parameter, value);
and using like this 并像这样使用
<TextBlock Text="{Binding LoggedTime,
Converter={StaticResource StringFormatConverter},
ConverterParameter='{}{0:HH:mm}'}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.