Application.LoadComponent exception for XAML resource
bent-rasmussen opened this issue · 6 comments
Describe the bug
Loading a XAML resource file (no code behind), using Application.LoadComponent, fails with a XAML load exception.
To Reproduce
Steps to reproduce the behavior:
- Add a XAML file to a WPF .NET Core 3.0 project
- Add the Interaction.Triggers element below the Window element
- Remove the code behind
- Make project Build Action=Resource for the file
- Use Application.LoadComponent to load the resource at startup
- Exception: Cannot set unknown member '{http://schemas.microsoft.com/xaml/behaviors}Interaction.Triggers'
Expected behavior
The component is loaded without an exception occurring.
Reproduction Link
https://github.com/Statical/issue-load-microsoft-xaml-behaviors-wpf
Background
Trying to upgrade a WPF application written in F# to .NET Core 3.0 - the issue occurs in C# as well, though -- but in C# projects one would typically set the build action for XAML to Resource and instead use Page. This has not been possible with F# projects.
@bent-rasmussen This sounds like an issue that is not behaviors specific. You should raise it with a simpler repro without behaviors on the F# GitHub repo instead: https://github.com/fsharp/fsharp
@mgoertz-msft why is this closed? The original report mentions, that the issue reproduces in C# too, and I just faced it in my C# project. The repro seems to be pretty simple too...
I faced it while following this guide: https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/
@mgoertz-msft I agree. This should not be closed. I encountered this same issue while moving a perfectly functioning project from the old "http://schemas.microsoft.com/expression/2010/interactivity” to “http://schemas.microsoft.com/xaml/behaviors“ following this guide: https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/
My project is a simple F# WPF project and it was working fine before the move. I will not post a repro here because it would be very close to what @bent-rasmussen has provided.
Furthermore, I disagree with @mgoertz-msft on raising it on the F# GitHub as:
-
The exception is thrown by Application.LoadComponent (from PresentationFramework.dll) on parsing a XAML with a reference to “http://schemas.microsoft.com/xaml/behaviors“. I don't see how being a F# project would interfere.
-
@lostmsu has provided a indication that the error is reproducible in C#.
Perhaps @lostmsu could provide a sample in C# for us to look into and reopen the issue?
I augmented @bent-rasmussen 's repro with a simple attached property, and the same issue occurs.
It appears to be a WPF Core issue, and not Behaviors.
ReproWithBasicProperty.zip
Thank you for checking @DVaughan!
@UsuarioBeta, @lostmsu and @bent-rasmussen, you may want to raise this issue with the simplified repro in the .NET Core WPF repo at https://github.com/dotnet/wpf
Thanks for the help! I'll surely do.