Skip to content

Commit fd5e92a

Browse files
committed
testapp: Add label and use Units.NET dependency to set text
1 parent a2a9c27 commit fd5e92a

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

UnitsNet.TestApps/UWP/MainPage.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
mc:Ignorable="d">
99

1010
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
11+
<TextBlock x:Name="MyTextBlock" Text="REPLACE ME" FontSize="30" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
1112
</Grid>
1213
</Page>
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
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;
174

185
namespace UWP
196
{
@@ -22,9 +9,24 @@ namespace UWP
229
/// </summary>
2310
public sealed partial class MainPage : Page
2411
{
12+
/// <summary>
13+
/// Example of public property returning WinRT component compatible type.
14+
/// </summary>
15+
public Temperature MyTemperature { get; set; }
16+
2517
public MainPage()
2618
{
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}";
2830
}
2931
}
3032
}

0 commit comments

Comments
 (0)