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

Blazor Desktop Components Not Supporting Partial Classes for defining code in the code behind partial class #31715

Closed
musictopia2 opened this issue Apr 12, 2021 · 7 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-desktop This issue is related to Blazor Desktop ✔️ Resolution: Duplicate Resolved as a duplicate of another issue investigate Status: Resolved
Milestone

Comments

@musictopia2
Copy link

When i create a partial class and define a method in that partial class, the code won't even compile.

Good news is it works fine if using a razor class library. The bad news is in blazor desktop does not work currently.
I hope the problem can be fixed. Otherwise, it would need to be clear that developers would have to know that if they want to split out into partial classes and have code in the partial class then they have to use a razor class library.

@javiercn javiercn added area-blazor Includes: Blazor, Razor Components feature-blazor-desktop This issue is related to Blazor Desktop labels Apr 12, 2021
@mkArtakMSFT mkArtakMSFT added this to the Next sprint planning milestone Apr 12, 2021
@ghost
Copy link

ghost commented Apr 12, 2021

Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@musictopia2
Copy link
Author

I have a little more information to provide about this problem.
I found out that if the project has any xaml files, then when i try to compile, then it will give compile errors. For example, if I override the OnInitialized on the component and compile, it will say it does not recognize the method. Even if I have custom methods like OnClick, same thing. However, if I take out the xaml file, then its okay. However, that means that a person for now can only do code behind if using a razor class library.

@musictopia2
Copy link
Author

I would like to know if you want me to create a simple repository to show that in every case, if you have a xaml file in a class library then partial classes with code behind does not work compile (even overriding the OnInitialized) in the partial class.

@Eilon
Copy link
Member

Eilon commented Jun 4, 2021

@musictopia2 thank you for the bug report. This is specifically in WPF projects? If so, it's being tracked by this issue: dotnet/wpf#4421. That issue also describes an easy workaround that can unblock you in the meantime.

@musictopia2
Copy link
Author

I have a question. Can WPF be used for blazor desktop when .net 6 is released? I hope so because there is one scenario that requires wpf that winui does not have and that is the ability to play mp3, videos. Or even being able to open popup windows. What I ended up doing for my workaround is creating a razor class library and having the project just reference that one. When I did that, then I was able to use partial classes for no problem. That was an acceptable workaround.

@Eilon
Copy link
Member

Eilon commented Jun 7, 2021

Yes, Blazor Desktop in WPF will be supported in .NET 6, along with WinForms, and .NET MAUI.

@Eilon
Copy link
Member

Eilon commented Jul 16, 2021

Closing because this looks like a dup of dotnet/maui#1516, which will be fixed in the next preview.

@Eilon Eilon closed this as completed Jul 16, 2021
@Eilon Eilon added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Jul 16, 2021
@ghost ghost added the Status: Resolved label Jul 16, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-desktop This issue is related to Blazor Desktop ✔️ Resolution: Duplicate Resolved as a duplicate of another issue investigate Status: Resolved
Projects
None yet
Development

No branches or pull requests

4 participants