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

Behavior change from .NET Core SDK 3.0.101 to 3.1.100 when generating MenuItems in WPF #2404

Open
davikor opened this issue Dec 16, 2019 · 6 comments
Assignees
Milestone

Comments

@davikor
Copy link

@davikor davikor commented Dec 16, 2019

I write a WPF app targeting .NET Framework 4.7.2 and added a global.json to control which version of dotnet CLI tools to be used in building and deploying.

In this app I define a menu of MenuItems of which some contain MenuItems as their children (a submenu). In one place I set the UsesItemContainerTemplate-property of the parent to true and define an ItemContainerTemplate containing a MenuItem at the root. As expected the parents ItemContainerGenerator respects this template and does not generate a menu item around this parents children.

After I switched the SDK version in global.json from 3.0.101 to 3.1.100 I noticed that this behavior changed. My submenuitems now are wrapped into an extra MenuItem.

I created a super-simple example-app that reproduces this issue. It can be found in this GitHub repo alongside with screenshots of the issue.

After checkout you can build and run this project in VS16.5 and it will behave as (I) expect it. Then you can change the SDK version in global.json to 3.1.100 and rebuild it in VS. When you run it now, you will see the unexpected result.

On a side note: When running dotnet clean/run from the console, the unexpected behavior always occurs, regardless of the SDK version defined in global.json. Unfortunately my knowledge of the dotnet / MSBuild system is not sufficient to further investigate here.

Also, I am not 100% sure whether this is the right place to post this issue. If there is a place better suited for my issue, please let me know and I will move this issue.

@davikor davikor changed the title Behavior change from .NET Core SDK 3.0.101 to 3.1.100 when generating MenuItems Behavior change from .NET Core SDK 3.0.101 to 3.1.100 when generating MenuItems in WPF Dec 17, 2019
@SusLes

This comment has been minimized.

Copy link

@SusLes SusLes commented Jan 7, 2020

@livarcocc

This comment has been minimized.

Copy link

@livarcocc livarcocc commented Jan 7, 2020

This seems like a WPF issue. Adding @rladuca and @vatsan-madhavan

@vatsan-madhavan vatsan-madhavan transferred this issue from dotnet/core Jan 7, 2020
@vatsan-madhavan

This comment has been minimized.

Copy link
Member

@vatsan-madhavan vatsan-madhavan commented Jan 7, 2020

Thanks - I’m transferring it over to wpf.

@gomathip02

This comment has been minimized.

Copy link

@gomathip02 gomathip02 commented Jan 9, 2020

@arpitmathur - is this related to the menu accessibility changes for 3.1?

@gomathip02 gomathip02 added this to the 5.0 milestone Jan 9, 2020
@davikor

This comment has been minimized.

Copy link
Author

@davikor davikor commented Jan 10, 2020

some additional information: When compiled with SDK version 3.0.101 the compiler adds the following x:Key attribute to the ItemContainerTemplate (in BAML): x:Key="{ItemContainerTemplateKey {x:Type local:MenuItemViewModel}}"

When compiled with SDK 3.1.100 (or using dotnet build instead of Visual Studio's MSBuild) the added x:Key attribute looks like this: x:Key="{DataTemplateKey {x:Type local:MenuItemViewModel}}"

(I checked my decompiled assembly for differences)

As a workaround, I tried to add the correct ItemTemplateKey to my XAML but it gets replaced during build. That is the only (obvious) difference I could spot. I also checked the platform on which both assemblies were run and both were run on the same runtime (.NET Framework 4.8.4075.0) so my guess is that the behavior change is somehow related to this key.

@inforithmics

This comment has been minimized.

Copy link

@inforithmics inforithmics commented Jan 17, 2020

I have the same issue targeting NET472.

Compiling the Project with the Legacy Project Format targeting 4.7.2 NET Framework
BAML: x:Key="{ItemContainerTemplateKey {x:Type ...

Converting the Project to the new Project Format targeting 4.7.2 NET Framework with .NET Core SDK 3.1.100
BAML: x:Key="{DataTemplateKey {x:Type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.