Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Samples to Unified Namespace Update, and other sample clean-up #289

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/managed-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,35 @@ jobs:
name: msbuild_binlog_Release_x64
path: msbuild.binlog
if-no-files-found: error

samples-build:
runs-on: windows-latest
steps:
- name: Checkout XamlBehaviors.git
uses: actions/checkout@v4

- name: Install the .NET 9.0.100 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.100

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Setup/Install NuGet 6.11.0
uses: nuget/setup-nuget@v2
with:
nuget-version: '6.11.0'

- name: NuGet Restore XAMLBehaviorsSample.sln
run: nuget restore samples\CS\XAMLBehaviorsSample.sln

- name: Build XAMLBehaviorsSample.sln
run: msbuild samples\CS\XAMLBehaviorsSample.sln /p:Configuration=Release -v:diag /bl

- name: Upload MSBuild binary log
uses: actions/upload-artifact@v4
with:
name: msbuild_samples_binlog_Release_x64
path: msbuild.binlog
if-no-files-found: error
35 changes: 10 additions & 25 deletions samples/CS/XAMLBehaviorsSample.sln
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
# Visual Studio Version 17
VisualStudioVersion = 17.12.35506.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XAMLBehaviorsSample", "XAMLBehaviorsSample\XAMLBehaviorsSample.csproj", "{050C4B73-9A9F-469B-9FA7-FB481894391F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xaml.Interactions", "..\..\src\BehaviorsSDKManaged\Microsoft.Xaml.Interactions\Microsoft.Xaml.Interactions.csproj", "{A338A7F2-9010-477B-8A6E-6C2B2495C33C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xaml.Interactivity", "..\..\src\BehaviorsSDKManaged\Microsoft.Xaml.Interactivity\Microsoft.Xaml.Interactivity.csproj", "{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xaml.Interactivity", "..\..\src\BehaviorsSDKManaged\Microsoft.Xaml.Interactivity\Microsoft.Xaml.Interactivity.csproj", "{A338A7F2-9010-477B-8A6E-6C2B2495C33C}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\..\src\BehaviorsSDKManaged\Microsoft.Xaml.Interactivity.Shared\Microsoft.Xaml.Interactivity.Shared.projitems*{7ffc1385-c3e1-487c-9a81-de48dd63ecb9}*SharedItemsImports = 4
..\..\src\BehaviorsSDKManaged\Microsoft.Xaml.Interactions.Shared\Microsoft.Xaml.Interactions.Shared.projitems*{a338a7f2-9010-477b-8a6e-6c2b2495c33c}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Expand All @@ -26,6 +20,8 @@ Global
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Debug|Any CPU.ActiveCfg = Debug|x86
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Debug|Any CPU.Build.0 = Debug|x86
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Debug|Any CPU.Deploy.0 = Debug|x86
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Debug|ARM.ActiveCfg = Debug|ARM
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Debug|ARM.Build.0 = Debug|ARM
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Debug|ARM.Deploy.0 = Debug|ARM
Expand All @@ -36,6 +32,8 @@ Global
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Debug|x86.Build.0 = Debug|x86
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Debug|x86.Deploy.0 = Debug|x86
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Release|Any CPU.ActiveCfg = Release|x86
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Release|Any CPU.Build.0 = Release|x86
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Release|Any CPU.Deploy.0 = Release|x86
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Release|ARM.ActiveCfg = Release|ARM
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Release|ARM.Build.0 = Release|ARM
{050C4B73-9A9F-469B-9FA7-FB481894391F}.Release|ARM.Deploy.0 = Release|ARM
Expand All @@ -61,27 +59,14 @@ Global
{A338A7F2-9010-477B-8A6E-6C2B2495C33C}.Release|x64.Build.0 = Release|x64
{A338A7F2-9010-477B-8A6E-6C2B2495C33C}.Release|x86.ActiveCfg = Release|x86
{A338A7F2-9010-477B-8A6E-6C2B2495C33C}.Release|x86.Build.0 = Release|x86
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Debug|ARM.ActiveCfg = Debug|ARM
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Debug|ARM.Build.0 = Debug|ARM
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Debug|x64.ActiveCfg = Debug|x64
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Debug|x64.Build.0 = Debug|x64
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Debug|x86.ActiveCfg = Debug|x86
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Debug|x86.Build.0 = Debug|x86
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Release|Any CPU.Build.0 = Release|Any CPU
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Release|ARM.ActiveCfg = Release|ARM
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Release|ARM.Build.0 = Release|ARM
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Release|x64.ActiveCfg = Release|x64
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Release|x64.Build.0 = Release|x64
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Release|x86.ActiveCfg = Release|x86
{7FFC1385-C3E1-487C-9A81-DE48DD63ECB9}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BAEA616E-866E-41F8-B6B8-ED0114DDB811}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\..\src\BehaviorsSDKManaged\Microsoft.Xaml.Interactivity.Shared\Microsoft.Xaml.Interactivity.Shared.projitems*{a338a7f2-9010-477b-8a6e-6c2b2495c33c}*SharedItemsImports = 4
EndGlobalSection
EndGlobal
183 changes: 86 additions & 97 deletions samples/CS/XAMLBehaviorsSample/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,129 +1,118 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Foundation.Metadata;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace XAMLBehaviorsSample
namespace XAMLBehaviorsSample;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// 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>
sealed partial class App : Application
public App()
{
/// <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();
this.Suspending += OnSuspending;
}
this.InitializeComponent();
this.Suspending += OnSuspending;
}

/// <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="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
/// <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="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{

#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif

Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();

rootFrame.NavigationFailed += OnNavigationFailed;
Frame rootFrame = Window.Current.Content as Frame;

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();

// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
rootFrame.NavigationFailed += OnNavigationFailed;

if (rootFrame.Content == null)
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
//TODO: Load state from previously suspended application
}

//if (DetectMobile())
//{
// rootFrame.Navigate(typeof(MainPage_Mobile), e.Arguments);
//}
//else
//{
rootFrame.Navigate(typeof(MainPage), e.Arguments);
// }
}
// Ensure the current window is active
Window.Current.Activate();
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
if (rootFrame.Content == null)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
//if (DetectMobile())
//{
// rootFrame.Navigate(typeof(MainPage_Mobile), e.Arguments);
//}
//else
//{
rootFrame.Navigate(typeof(MainPage), e.Arguments);
// }
}
// Ensure the current window is active
Window.Current.Activate();
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}

private bool DetectMobile()
{
bool isHardwareButtonsAPIPresent =
ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons");

if (isHardwareButtonsAPIPresent)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
return true;
}

private bool DetectMobile()
else
{
bool isHardwareButtonsAPIPresent =
ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons");

if (isHardwareButtonsAPIPresent)
{
return true;
}
else
{
return false;
}
return false;
}
}
}

This file was deleted.

Loading