1
- using System ;
2
- using System . Collections . Generic ;
3
- using System . IO ;
4
- using System . Linq ;
5
- using System . Runtime . InteropServices . WindowsRuntime ;
6
- using Windows . Foundation ;
7
- using Windows . Foundation . Collections ;
8
- using Windows . UI . Xaml ;
9
- using Windows . UI . Xaml . Controls ;
10
- using Windows . UI . Xaml . Controls . Primitives ;
11
- using Windows . UI . Xaml . Data ;
12
- using Windows . UI . Xaml . Input ;
13
- using Windows . UI . Xaml . Media ;
14
- using Windows . UI . Xaml . Navigation ;
15
-
16
- // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
1
+ using Windows . UI . Xaml . Controls ;
2
+ using UnitsNet ;
3
+ using UnitsNet . Units ;
17
4
18
5
namespace UWP
19
6
{
@@ -22,9 +9,24 @@ namespace UWP
22
9
/// </summary>
23
10
public sealed partial class MainPage : Page
24
11
{
12
+ /// <summary>
13
+ /// Example of public property returning WinRT component compatible type.
14
+ /// </summary>
15
+ public Temperature MyTemperature { get ; set ; }
16
+
25
17
public MainPage ( )
26
18
{
27
- this . InitializeComponent ( ) ;
19
+ InitializeComponent ( ) ;
20
+
21
+ // Test some variations, From() constructors, Parse(), As()
22
+ string celsius = Temperature . FromDegreesCelsius ( 100 ) . ToString ( TemperatureUnit . DegreeCelsius ) ;
23
+ string fahrenheit = Temperature . Parse ( "100 °C" ) . ToString ( TemperatureUnit . DegreeFahrenheit ) ;
24
+ string kelvin = Temperature . FromDegreesCelsius ( Temperature . Parse ( fahrenheit ) . As ( TemperatureUnit . DegreeCelsius ) ) . ToString ( TemperatureUnit . Kelvin ) ;
25
+
26
+ // Arithmetic operators not allowed in WinRT Components, but SHOULD be allowed in UWP C# apps
27
+ // new Temperature(5) + new Temperature(6)
28
+
29
+ MyTextBlock . Text = $ "{ celsius } = { fahrenheit } = { kelvin } ";
28
30
}
29
31
}
30
32
}
0 commit comments