User Tools

Site Tools


notes:uwp:converters

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
notes:uwp:converters [2017/03/08]
admin
notes:uwp:converters [2017/03/10]
admin [Examples]
Line 69: Line 69:
     </​Grid.ColumnDefinitions>​     </​Grid.ColumnDefinitions>​
 </​Grid>​ </​Grid>​
 +</​code>​
 +
 +
 +Example: DoubleToTimeSpanConverter
 +
 +<code csharp>
 +class DoubleToTimeSpanConverter : IValueConverter
 +{
 +    public object Convert(object value, Type targetType, object parameter, string language)
 +    {
 +        double hours = (double)value;​
 +        TimeSpan span = TimeSpan.FromHours(hours);​
 +        return span;
 +    }
 +
 +    public object ConvertBack(object value, Type targetType, object parameter, string language)
 +    {
 +        TimeSpan span = (TimeSpan)value;​
 +        double hours = span.TotalHours;​
 +        return hours;
 +    }
 +}
 </​code>​ </​code>​
  
notes/uwp/converters.txt ยท Last modified: 2017/03/10 by admin