Windows
Windows
With the announcement of the , we are pleased to announce we have posted on the released versions of the . The allows your WPF or Winforms application to quickly and easily access Windows functionality like , , , and
Accessing these APIs in your project is as simple as adding the NuGet to your project.
Getting Started
Step 1: Configure your project to support
Step 2: Add the Microsoft.Windows.SDK.Contracts NuGet package to your project
Windows 10 version 1803
Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.17134.1000
Windows 10 version 1809
Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.17763.1000
Windows 10 version 1903
Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.18362.2005
Step 3: Get coding
By adding one of the above NuGet packages, you now have access to calling the in your project.
For example, this snippet shows a WPF Message box displaying the latitude and longitude coordinates:
private async void Button_Click(object sender, RoutedEventArgs e)
{
var locator = new Windows.Devices.Geolocation.Geolocator();
var location = await locator.GetGeopositionAsync();
var position = location.Coordinate.Point.Position;
var latlong = string.Format("lat:{0}, long:{1}", position.Latitude, position.Longitude);
var result = MessageBox.Show(latlong);
}
Many partners are already using these NuGet files. If you check out a project that is already using these NuGet packages, see the .
The post appeared first on .
Accessing these APIs in your project is as simple as adding the NuGet to your project.
Getting Started
Step 1: Configure your project to support
Step 2: Add the Microsoft.Windows.SDK.Contracts NuGet package to your project
- Open the
- Install the package that includes the you want to target. Currently the following are supported:
Windows 10 version 1803
Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.17134.1000
Windows 10 version 1809
Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.17763.1000
Windows 10 version 1903
Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.18362.2005
Step 3: Get coding
By adding one of the above NuGet packages, you now have access to calling the in your project.
For example, this snippet shows a WPF Message box displaying the latitude and longitude coordinates:
private async void Button_Click(object sender, RoutedEventArgs e)
{
var locator = new Windows.Devices.Geolocation.Geolocator();
var location = await locator.GetGeopositionAsync();
var position = location.Coordinate.Point.Position;
var latlong = string.Format("lat:{0}, long:{1}", position.Latitude, position.Longitude);
var result = MessageBox.Show(latlong);
}
Many partners are already using these NuGet files. If you check out a project that is already using these NuGet packages, see the .
The post appeared first on .