-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from egvijayanand/working
Using .NET MAUI Community Toolkit Maps in WinUI 3 App
- Loading branch information
Showing
47 changed files
with
850 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Application | ||
x:Class="MapsApp.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:MapsApp" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" /> | ||
<!-- Other merged dictionaries here --> | ||
</ResourceDictionary.MergedDictionaries> | ||
<!-- Other app resources here --> | ||
<Color x:Key="Primary">#512BD4</Color> | ||
|
||
<SolidColorBrush x:Key="PrimaryBrush" Color="{StaticResource Primary}" /> | ||
<SolidColorBrush x:Key="WhiteBrush" Color="White" /> | ||
<SolidColorBrush x:Key="BlackBrush" Color="Black" /> | ||
|
||
<x:Double x:Key="AppFontSize">14</x:Double> | ||
|
||
<Style x:Key="MyLabel" TargetType="TextBlock"> | ||
<Setter Property="Foreground" | ||
Value="{StaticResource PrimaryBrush}" /> | ||
</Style> | ||
|
||
<Style x:Key="Action" TargetType="Button"> | ||
<Setter Property="FontSize" | ||
Value="{StaticResource AppFontSize}" /> | ||
<Setter Property="Padding" | ||
Value="14,10" /> | ||
</Style> | ||
|
||
<Style x:Key="PrimaryAction" | ||
TargetType="Button" | ||
BasedOn="{StaticResource Action}"> | ||
<Setter Property="Background" | ||
Value="{StaticResource PrimaryBrush}" /> | ||
<Setter Property="CornerRadius" | ||
Value="8" /> | ||
<Setter Property="Foreground" | ||
Value="{StaticResource WhiteBrush}" /> | ||
</Style> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace MapsApp | ||
{ | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
/// <summary> | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when the application is launched normally by the end user. Other entry points | ||
/// will be used such as when the application is launched to open a specific file. | ||
/// </summary> | ||
/// <param name="args">Details about the launch request and process.</param> | ||
protected override void OnLaunched(LaunchActivatedEventArgs args) | ||
{ | ||
m_window = new MainWindow(); | ||
m_window?.Activate(); | ||
} | ||
|
||
private Window? m_window; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+283 Bytes
src/NET_8/MapsApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using CommunityToolkit.Maui.Maps.Handlers; | ||
using Microsoft.Maui.Controls.Maps; | ||
using Microsoft.Maui.Hosting; | ||
using System.Reflection; | ||
|
||
namespace MapsApp.Extensions; | ||
|
||
public static class AppBuilderExtensions | ||
{ | ||
public static MauiAppBuilder UseMauiToolkitMaps(this MauiAppBuilder builder, string key) | ||
{ | ||
SetMapsKey(key); | ||
builder.ConfigureMauiHandlers(handlers => handlers.AddHandler<Map, MapHandlerWindows>()); | ||
return builder; | ||
|
||
static void SetMapsKey(string key) | ||
{ | ||
var mapsKey = typeof(MapHandlerWindows).GetField("MapsKey", BindingFlags.NonPublic | BindingFlags.Static); | ||
mapsKey?.SetValue(null, key); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
global using Microsoft.UI.Xaml; | ||
|
||
global using MapsApp; | ||
global using MapsApp.Views; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework> | ||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion> | ||
<OutputType>WinExe</OutputType> | ||
|
||
<!-- WinUI 3 --> | ||
<UseWinUI>true</UseWinUI> | ||
<EnableMsixTooling>true</EnableMsixTooling> | ||
<WindowsPackageType>None</WindowsPackageType> | ||
|
||
<!-- Project Options --> | ||
<Nullable>enable</Nullable> | ||
<!-- <ImplicitUsings>enable</ImplicitUsings> --> | ||
<RootNamespace>MapsApp</RootNamespace> | ||
<EnableDefaultXamlItems>false</EnableDefaultXamlItems> | ||
|
||
<!-- App Options --> | ||
<UseRidGraph>true</UseRidGraph> | ||
<Platforms>x86;x64;arm64</Platforms> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
<PublishProfile>win10-$(Platform).pubxml</PublishProfile> | ||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="Assets\SplashScreen.scale-200.png" /> | ||
<Content Include="Assets\LockScreenLogo.scale-200.png" /> | ||
<Content Include="Assets\Square150x150Logo.scale-200.png" /> | ||
<Content Include="Assets\Square44x44Logo.scale-200.png" /> | ||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" /> | ||
<Content Include="Assets\StoreLogo.png" /> | ||
<Content Include="Assets\Wide310x150Logo.scale-200.png" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CommunityToolkit.Maui.Maps" Version="2.0.0" /> | ||
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" /> | ||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.7" /> | ||
<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="8.0.7" /> | ||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.*" /> | ||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.*" /> | ||
<Manifest Include="$(ApplicationManifest)" /> | ||
</ItemGroup> | ||
|
||
<!-- | ||
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging | ||
Tools extension to be activated for this project even if the Windows App SDK Nuget | ||
package has not yet been restored. | ||
--> | ||
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'"> | ||
<ProjectCapability Include="Msix" /> | ||
</ItemGroup> | ||
|
||
<!-- | ||
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution | ||
Explorer "Package and Publish" context menu entry to be enabled for this project even if | ||
the Windows App SDK Nuget package has not yet been restored. | ||
--> | ||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'"> | ||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.33103.201 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{F96C4E64-BE43-4154-A47D-AB08A79065BB}") = "MapsApp", "MapsApp.csproj", "{5264FDB3-5545-4109-9B71-08DD9FADB4D0}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|arm64 = Debug|arm64 | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|arm64 = Release|arm64 | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Debug|arm64.ActiveCfg = Debug|arm64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Debug|arm64.Build.0 = Debug|arm64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Debug|arm64.Deploy.0 = Debug|arm64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Debug|x64.ActiveCfg = Debug|x64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Debug|x64.Build.0 = Debug|x64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Debug|x64.Deploy.0 = Debug|x64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Debug|x86.ActiveCfg = Debug|x86 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Debug|x86.Build.0 = Debug|x86 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Debug|x86.Deploy.0 = Debug|x86 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Release|arm64.ActiveCfg = Release|arm64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Release|arm64.Build.0 = Release|arm64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Release|arm64.Deploy.0 = Release|arm64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Release|x64.ActiveCfg = Release|x64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Release|x64.Build.0 = Release|x64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Release|x64.Deploy.0 = Release|x64 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Release|x86.ActiveCfg = Release|x86 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Release|x86.Build.0 = Release|x86 | ||
{5264FDB3-5545-4109-9B71-08DD9FADB4D0}.Release|x86.Deploy.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {35FE2F82-41AC-40AC-B3A1-A496E1DB3D9B} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using MauiApplication = Microsoft.Maui.Controls.Application; | ||
|
||
namespace MapsApp | ||
{ | ||
public partial class MyApp : MauiApplication | ||
{ | ||
public MyApp() | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<Package | ||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" | ||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" | ||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" | ||
IgnorableNamespaces="uap rescap"> | ||
|
||
<Identity | ||
Name="4b915f98-c95c-41a2-83dd-8ca3df60e938" | ||
Publisher="CN=User Name" | ||
Version="1.0.0.0" /> | ||
|
||
<Properties> | ||
<DisplayName>MapsApp</DisplayName> | ||
<PublisherDisplayName>User Name</PublisherDisplayName> | ||
<Logo>Assets\StoreLogo.png</Logo> | ||
</Properties> | ||
|
||
<Dependencies> | ||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" /> | ||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" /> | ||
</Dependencies> | ||
|
||
<Resources> | ||
<Resource Language="x-generate"/> | ||
</Resources> | ||
|
||
<Applications> | ||
<Application Id="App" | ||
Executable="$targetnametoken$.exe" | ||
EntryPoint="$targetentrypoint$"> | ||
<uap:VisualElements | ||
DisplayName="MapsApp" | ||
Description="MapsApp" | ||
BackgroundColor="transparent" | ||
Square150x150Logo="Assets\Square150x150Logo.png" | ||
Square44x44Logo="Assets\Square44x44Logo.png"> | ||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" /> | ||
<uap:SplashScreen Image="Assets\SplashScreen.png" /> | ||
</uap:VisualElements> | ||
</Application> | ||
</Applications> | ||
|
||
<Capabilities> | ||
<rescap:Capability Name="runFullTrust" /> | ||
</Capabilities> | ||
</Package> |
20 changes: 20 additions & 0 deletions
20
src/NET_8/MapsApp/Properties/PublishProfiles/win10-arm64.pubxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
https://go.microsoft.com/fwlink/?LinkID=208121. | ||
--> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<PublishProtocol>FileSystem</PublishProtocol> | ||
<Platform>arm64</Platform> | ||
<RuntimeIdentifier>win10-arm64</RuntimeIdentifier> | ||
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir> | ||
<SelfContained>true</SelfContained> | ||
<PublishSingleFile>False</PublishSingleFile> | ||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun> | ||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun> | ||
<!-- | ||
See https://github.com/microsoft/CsWinRT/issues/373 | ||
<PublishTrimmed>True</PublishTrimmed> | ||
--> | ||
</PropertyGroup> | ||
</Project> |
20 changes: 20 additions & 0 deletions
20
src/NET_8/MapsApp/Properties/PublishProfiles/win10-x64.pubxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
https://go.microsoft.com/fwlink/?LinkID=208121. | ||
--> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<PublishProtocol>FileSystem</PublishProtocol> | ||
<Platform>x64</Platform> | ||
<RuntimeIdentifier>win10-x64</RuntimeIdentifier> | ||
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir> | ||
<SelfContained>true</SelfContained> | ||
<PublishSingleFile>False</PublishSingleFile> | ||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun> | ||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun> | ||
<!-- | ||
See https://github.com/microsoft/CsWinRT/issues/373 | ||
<PublishTrimmed>True</PublishTrimmed> | ||
--> | ||
</PropertyGroup> | ||
</Project> |
20 changes: 20 additions & 0 deletions
20
src/NET_8/MapsApp/Properties/PublishProfiles/win10-x86.pubxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
https://go.microsoft.com/fwlink/?LinkID=208121. | ||
--> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<PublishProtocol>FileSystem</PublishProtocol> | ||
<Platform>x86</Platform> | ||
<RuntimeIdentifier>win10-x86</RuntimeIdentifier> | ||
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir> | ||
<SelfContained>true</SelfContained> | ||
<PublishSingleFile>False</PublishSingleFile> | ||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun> | ||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun> | ||
<!-- | ||
See https://github.com/microsoft/CsWinRT/issues/373 | ||
<PublishTrimmed>True</PublishTrimmed> | ||
--> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"profiles": { | ||
"MapsApp (Package)": { | ||
"commandName": "MsixPackage" | ||
}, | ||
"MapsApp (Unpackaged)": { | ||
"commandName": "Project" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Maps; | ||
using Microsoft.Maui.Devices.Sensors; | ||
using Microsoft.Maui.Maps; | ||
|
||
namespace MapsApp.Views; | ||
|
||
public class HomePage : ContentPage | ||
{ | ||
public HomePage() | ||
{ | ||
Content = new Map(new MapSpan(new Location(47.643543, -122.130821), 0.01, 0.01)); | ||
} | ||
} |
Oops, something went wrong.