Skip to content

Modernizes XAMLBehaviors sample to SDK-style - #199

Merged
Brian Lagunas (brianlagunas) merged 1 commit into
mainfrom
sample-project-sdk
Apr 6, 2026
Merged

Modernizes XAMLBehaviors sample to SDK-style#199
Brian Lagunas (brianlagunas) merged 1 commit into
mainfrom
sample-project-sdk

Conversation

@brianlagunas

Copy link
Copy Markdown
Collaborator

Description of Change

Converts the XAMLBehaviorsSample project to the modern SDK-style format. This change significantly simplifies the project file structure, making it more concise and easier to manage.

Key changes include:

  • Migrates the .csproj file to the SDK format, removing explicit file listings and redundant references.
  • Introduces multi-targeting for net462 and net8.0-windows to ensure compatibility with both .NET Framework and modern .NET.
  • Deletes the App.config and Properties/AssemblyInfo.cs files, as their content is now either implicit or managed through project properties in the SDK-style format.

This modernization aligns the sample project with current .NET development practices and improves maintainability.

Bugs Fixed

API Changes

None

Behavioral Changes

None. The sample application's functionality remains unchanged.

PR Checklist

  • Has tests (This is a sample project, so no specific tests are added for this migration)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard

Updates the sample project to use the modern .NET SDK-style format and enables multi-targeting for .NET 4.6.2 and .NET 8.0. This change simplifies the project file and removes redundant assembly information and configuration files.
@brianlagunas
Brian Lagunas (brianlagunas) merged commit c8ba172 into main Apr 6, 2026
5 checks passed
@brianlagunas
Brian Lagunas (brianlagunas) deleted the sample-project-sdk branch April 6, 2026 17:42
@jizc

Copy link
Copy Markdown

Brian Lagunas (@brianlagunas) this change breaks the PlaySoundAction sample. This is because it depends on a relative path to the Assets/Cheer.mp3 file.

My PR #187 dealt with this problem by adding <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>, but since you added multi-targeting that is not an option.

The simplest fix would be to add ../ to the relative paths here:
https://github.com/microsoft/XamlBehaviorsWpf/blob/main/samples/XAMLBehaviorsSample/XAMLBehaviorsSample/PlaySoundControl.xaml#L31
and here:
https://github.com/microsoft/XamlBehaviorsWpf/blob/main/samples/XAMLBehaviorsSample/XAMLBehaviorsSample/PlaySoundControl.xaml#L43

@brianlagunas

Brian Lagunas (brianlagunas) commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

Jan Ivar Carlsen (@jizc) good find. Thanks for letting me know. Actually, by adding support for multi-targeting we found a bug in the implementation of the sample. A relative path should not have been used there because it was traversing to find the file in the project source and not using the file that was copied into the debug folder with the executable.

this will be fixed with #200

This was referenced Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants