-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
In.NET 5.0 WPF, a window in a container cannot call a style resource in app.xaml #4538
Comments
This reproduces in 4.8. This seems to be a bug in the compiler actually. When |
...which seems to be an intentional optimization: Lines 163 to 180 in 89d172d
|
@lifuhua123 and this code also hints a workaround: set any property on the |
I think this issue is a duplicate of this one: #4457. As I said in this comment: #4457 (comment), the issue is caused by PresentationBuildTasks.dll so it will only apply to SDK-style csproj (.Net Framework or .Net Core) but this issue does not reproduce when using the old csproj style of .Net Framework. |
This one reproduces for me with the old project file. That said, I agree this looks caused by the same underlying issue. |
@ryalanms I think this is meant to be a bug report rather than a question, but perhaps can be closed as duplicate. |
@ThomasGoulet73 This problem is different from # 4457. Please look at the sample |
@miloush You're right, I added shutdownMode =" onLastWindowClose "and the program starts, but why? |
@lifuhua123 The problem is different but the cause is the same. You can also use the same workaround in #4457 of adding another style to your resource dictionary in App.xaml. The bug is that it should generate the InitializeComponent method even if there is only one Style in the resource dictionary. By adding a property, you trigger the generation of InitializeComponent that was already suppose to occur when there is on style. |
Okay, so is this a problem or a bug? I tried another method, the program can also start. Set shutdownMode =" onLastWindowClose ", but don't know why? @ThomasGoulet73 |
…hen App contains a single item. Fixes dotnet#4538 Fixes dotnet#4457 Fixes dotnet#2926 Fixes dotnet#2543 Fixes dotnet#6198
This bug should be fixed by #8853. For now, you can workaround this issue by adding a dummy item in |
In.NET 5.0 WPF, a window in a container cannot call a style resource in app.xaml ,
as shown in the figure :
The text was updated successfully, but these errors were encountered: