-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e1698c
commit ceaf495
Showing
82 changed files
with
2,183 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31220.234 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UsingMessagingCenter", "UsingMessagingCenter\UsingMessagingCenter\UsingMessagingCenter.csproj", "{1D41DB41-5963-46EC-B5A8-E821226806FC}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UsingMessagingCenter.WinUI", "UsingMessagingCenter\UsingMessagingCenter.WinUI\UsingMessagingCenter.WinUI.csproj", "{6D2D0708-5104-4C7B-8917-7B75582D87D3}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1D41DB41-5963-46EC-B5A8-E821226806FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1D41DB41-5963-46EC-B5A8-E821226806FC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1D41DB41-5963-46EC-B5A8-E821226806FC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU | ||
{1D41DB41-5963-46EC-B5A8-E821226806FC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1D41DB41-5963-46EC-B5A8-E821226806FC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{1D41DB41-5963-46EC-B5A8-E821226806FC}.Release|Any CPU.Deploy.0 = Release|Any CPU | ||
{6D2D0708-5104-4C7B-8917-7B75582D87D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6D2D0708-5104-4C7B-8917-7B75582D87D3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6D2D0708-5104-4C7B-8917-7B75582D87D3}.Debug|Any CPU.Deploy.0 = Debug|Any CPU | ||
{6D2D0708-5104-4C7B-8917-7B75582D87D3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6D2D0708-5104-4C7B-8917-7B75582D87D3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{6D2D0708-5104-4C7B-8917-7B75582D87D3}.Release|Any CPU.Deploy.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572} | ||
EndGlobalSection | ||
EndGlobal |
26 changes: 26 additions & 0 deletions
26
UsingMessagingCenter/UsingMessagingCenter/Directory.Build.targets
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,26 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<!-- Required - Enable Launch Profiles for .NET 6 iOS/Android --> | ||
<_KeepLaunchProfiles>true</_KeepLaunchProfiles> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<!-- Required - Setup Single Project features --> | ||
<ProjectCapability Include="MauiSingleProject" /> | ||
|
||
<!-- Optional - Enables a list of TFM's and device categories in the debug menu --> | ||
<!-- This allows easily toggling of debug target TFM by selecting the platform --> | ||
<!-- If removed, Top level debug targets show as a list of devices for the selected TFM --> | ||
<ProjectCapability Include="XamarinStaticLaunchProfiles" /> | ||
</ItemGroup> | ||
|
||
<!-- Required - Skip the runtime settings --> | ||
<PropertyGroup> | ||
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles> | ||
</PropertyGroup> | ||
|
||
<!-- Required - Overwrite tasks that are not needed when multitargeting --> | ||
<Target Name="ValidateWinUIPlatform" /> | ||
<Target Name="BinPlaceBootstrapDll" /> | ||
|
||
</Project> |
8 changes: 8 additions & 0 deletions
8
...essagingCenter/UsingMessagingCenter/UsingMessagingCenter.WinUI/Platforms/Windows/App.xaml
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,8 @@ | ||
<maui:MauiWinUIApplication | ||
x:Class="UsingMessagingCenter.WinUI.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:maui="using:Microsoft.Maui" | ||
xmlns:local="using:UsingMessagingCenter.WinUI"> | ||
|
||
</maui:MauiWinUIApplication> |
33 changes: 33 additions & 0 deletions
33
...agingCenter/UsingMessagingCenter/UsingMessagingCenter.WinUI/Platforms/Windows/App.xaml.cs
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,33 @@ | ||
using Microsoft.Maui; | ||
using Microsoft.UI.Xaml; | ||
using Windows.ApplicationModel; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace UsingMessagingCenter.WinUI | ||
{ | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App : MauiWinUIApplication | ||
{ | ||
/// <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(); | ||
} | ||
|
||
protected override IStartup OnCreateStartup() => new Startup(); | ||
|
||
protected override void OnLaunched(LaunchActivatedEventArgs args) | ||
{ | ||
base.OnLaunched(args); | ||
|
||
Microsoft.Maui.Essentials.Platform.OnLaunched(args); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...er/UsingMessagingCenter/UsingMessagingCenter.WinUI/Platforms/Windows/Package.appxmanifest
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,58 @@ | ||
<?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="1804C78F-1A15-46A4-AF11-0492B2A6B04A" | ||
Publisher="CN=User Name" | ||
Version="1.0.0.0" /> | ||
|
||
<Properties> | ||
<DisplayName>UsingMessagingCenter</DisplayName> | ||
<PublisherDisplayName>Microsoft</PublisherDisplayName> | ||
<Logo>Assets\appiconStoreLogo.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="UsingMessagingCenter" | ||
Description="UsingMessagingCenter" | ||
BackgroundColor="transparent" | ||
Square150x150Logo="Assets\appiconMediumTile.png" | ||
Square44x44Logo="Assets\appiconLogo.png"> | ||
<uap:DefaultTile | ||
Wide310x150Logo="Assets\appiconWideTile.png" | ||
Square71x71Logo="Assets\appiconSmallTile.png" | ||
Square310x310Logo="Assets\appiconLargeTile.png" | ||
ShortName="UsingMessagingCenter"> | ||
<uap:ShowNameOnTiles> | ||
<uap:ShowOn Tile="square150x150Logo"/> | ||
<uap:ShowOn Tile="wide310x150Logo"/> | ||
</uap:ShowNameOnTiles> | ||
</uap:DefaultTile > | ||
<uap:SplashScreen Image="Assets\appiconfgSplashScreen.png" /> | ||
</uap:VisualElements> | ||
</Application> | ||
</Applications> | ||
|
||
<Capabilities> | ||
<rescap:Capability Name="runFullTrust" /> | ||
</Capabilities> | ||
|
||
</Package> |
15 changes: 15 additions & 0 deletions
15
...gingCenter/UsingMessagingCenter/UsingMessagingCenter.WinUI/Platforms/Windows/app.manifest
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,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<assemblyIdentity version="1.0.0.0" name="UsingMessagingCenter.WinUI.app"/> | ||
|
||
<application xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<windowsSettings> | ||
<!-- The combination of below two tags have the following effect: | ||
1) Per-Monitor for >= Windows 10 Anniversary Update | ||
2) System < Windows 10 Anniversary Update | ||
--> | ||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware> | ||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness> | ||
</windowsSettings> | ||
</application> | ||
</assembly> |
7 changes: 7 additions & 0 deletions
7
...gingCenter/UsingMessagingCenter/UsingMessagingCenter.WinUI/Properties/launchSettings.json
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,7 @@ | ||
{ | ||
"profiles": { | ||
"UsingMessagingCenter.WinUI": { | ||
"commandName": "MsixPackage" | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...gCenter/UsingMessagingCenter/UsingMessagingCenter.WinUI/UsingMessagingCenter.WinUI.csproj
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,61 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0-windows10.0.19041</TargetFrameworks> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
<OutputType>WinExe</OutputType> | ||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
<RootNamespace>UsingMessagingCenter</RootNamespace> | ||
|
||
<!-- Required - Enable Single Project for WinUI --> | ||
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling> | ||
<WindowsPackageType>MSIX</WindowsPackageType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- App Icon --> | ||
<MauiImage | ||
Include="..\UsingMessagingCenter\Resources\appicon.svg" | ||
Link="Resources\appicon.svg" | ||
ForegroundFile="..\UsingMessagingCenter\Resources\appiconfg.svg" | ||
IsAppIcon="true" | ||
Color="#512BD4" /> | ||
|
||
<!-- Splash Screen --> | ||
<MauiSplashScreen | ||
Include="..\UsingMessagingCenter\Resources\appiconfg.svg" | ||
Link="Resources\appiconfg.svg" | ||
Color="#512BD4" /> | ||
|
||
<!-- Images --> | ||
<MauiImage | ||
Include="..\UsingMessagingCenter\Resources\Images\*" | ||
Link="Resources\Images\%(Filename)%(Extension)" /> | ||
|
||
<!-- Custom Fonts --> | ||
<MauiFont | ||
Include="..\UsingMessagingCenter\Resources\Fonts\*" | ||
Link="Resources\Fonts\%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile | ||
Include="..\UsingMessagingCenter\**\*.cs" | ||
Exclude="..\UsingMessagingCenter\bin\**;..\UsingMessagingCenter\obj\**;..\UsingMessagingCenter\Platforms\**" | ||
Link="%(RecursiveDir)%(Filename)%(Extension)"/> | ||
<MauiXaml | ||
Include="..\UsingMessagingCenter\**\*.xaml" | ||
Exclude="..\UsingMessagingCenter\bin\**;..\UsingMessagingCenter\obj\**" | ||
Link="%(RecursiveDir)%(FileName)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.ProjectReunion" Version="0.8.0" /> | ||
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.8.0" /> | ||
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.8.0" /> | ||
<PackageReference Include="Microsoft.ProjectReunion.InteractiveExperiences" Version="0.8.0" NoWarn="NU1701" /> | ||
</ItemGroup> | ||
|
||
</Project> |
7 changes: 7 additions & 0 deletions
7
UsingMessagingCenter/UsingMessagingCenter/UsingMessagingCenter/App.xaml
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,7 @@ | ||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls" | ||
xmlns:local="clr-namespace:UsingMessagingCenter" | ||
x:Class="UsingMessagingCenter.App" | ||
windows:Application.ImageDirectory="Assets"> | ||
</Application> |
14 changes: 14 additions & 0 deletions
14
UsingMessagingCenter/UsingMessagingCenter/UsingMessagingCenter/App.xaml.cs
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 Application = Microsoft.Maui.Controls.Application; | ||
|
||
namespace UsingMessagingCenter | ||
{ | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
MainPage = new MainPage(); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
UsingMessagingCenter/UsingMessagingCenter/UsingMessagingCenter/MainPage.xaml
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="UsingMessagingCenter.MainPage"> | ||
<StackLayout Margin="20,35,20,20"> | ||
<Label Text="MessagingCenter Demo" | ||
FontAttributes="Bold" | ||
HorizontalOptions="Center" /> | ||
<Button Text="Say Hi" | ||
Clicked="OnSayHiButtonClicked" /> | ||
<Button Text="Say Hi to John" | ||
Clicked="OnSayHiToJohnButtonClicked" /> | ||
<Button Text="Unsubscribe" | ||
Clicked="OnUnsubscribeButtonClicked" /> | ||
<ListView ItemsSource="{Binding Greetings}" /> | ||
</StackLayout> | ||
</ContentPage> |
36 changes: 36 additions & 0 deletions
36
UsingMessagingCenter/UsingMessagingCenter/UsingMessagingCenter/MainPage.xaml.cs
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,36 @@ | ||
using Microsoft.Maui.Controls; | ||
using System; | ||
|
||
namespace UsingMessagingCenter | ||
{ | ||
public partial class MainPage : ContentPage | ||
{ | ||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
BindingContext = new MainPageViewModel(); | ||
|
||
// Subscribe to a message (which the ViewModel has also subscribed to) to display an alert | ||
MessagingCenter.Subscribe<MainPage, string>(this, "Hi", async (sender, arg) => | ||
{ | ||
await DisplayAlert("Message received", "arg=" + arg, "OK"); | ||
}); | ||
} | ||
|
||
void OnSayHiButtonClicked(object sender, EventArgs e) | ||
{ | ||
MessagingCenter.Send<MainPage>(this, "Hi"); | ||
} | ||
|
||
void OnSayHiToJohnButtonClicked(object sender, EventArgs e) | ||
{ | ||
MessagingCenter.Send<MainPage, string>(this, "Hi", "John"); | ||
} | ||
|
||
async void OnUnsubscribeButtonClicked(object sender, EventArgs e) | ||
{ | ||
MessagingCenter.Unsubscribe<MainPage, string>(this, "Hi"); | ||
await DisplayAlert("Unsubscribed", "This page has stopped listening, so no more alerts. However, the ViewModel is still receiving messages.", "OK"); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
UsingMessagingCenter/UsingMessagingCenter/UsingMessagingCenter/MainPageCS.cs
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,52 @@ | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace UsingMessagingCenter | ||
{ | ||
public class MainPageCS : ContentPage | ||
{ | ||
public MainPageCS() | ||
{ | ||
BindingContext = new MainPageViewModel(); | ||
|
||
Label label = new Label { Text = "MessagingCenter Demo", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center }; | ||
|
||
// Send messages when buttons are pressed | ||
Button button1 = new Button { Text = "Say Hi" }; | ||
button1.Clicked += (sender, e) => | ||
{ | ||
MessagingCenter.Send<MainPageCS>(this, "Hi"); | ||
}; | ||
Button button2 = new Button { Text = "Say Hi to John" }; | ||
button2.Clicked += (sender, e) => | ||
{ | ||
MessagingCenter.Send<MainPageCS, string>(this, "Hi", "John"); | ||
}; | ||
|
||
Button button3 = new Button { Text = "Unsubscribe from alert" }; | ||
button3.Clicked += async (sender, e) => | ||
{ | ||
MessagingCenter.Unsubscribe<MainPageCS, string>(this, "Hi"); | ||
await DisplayAlert("Unsubscribed", | ||
"This page has stopped listening, so no more alerts; however the ViewModel is still receiving messages.", | ||
"OK"); | ||
}; | ||
|
||
// Subscribe to a message (which the ViewModel has also subscribed to) to display an alert | ||
MessagingCenter.Subscribe<MainPageCS, string>(this, "Hi", async (sender, arg) => | ||
{ | ||
await DisplayAlert("Message Received", "arg=" + arg, "OK"); | ||
}); | ||
|
||
ListView listView = new ListView(); | ||
listView.SetBinding(ItemsView<Cell>.ItemsSourceProperty, "Greetings"); | ||
|
||
Content = new StackLayout | ||
{ | ||
Padding = new Thickness(20, 35, 20, 20), | ||
Children = { label, button1, button2, button3, listView } | ||
}; | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.