Open davikor opened 4 years ago
@livarcocc
This seems like a WPF issue. Adding @rladuca and @vatsan-madhavan
Thanks - I’m transferring it over to wpf.
@arpitmathur - is this related to the menu accessibility changes for 3.1?
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.
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
Reproduced the same bug. Waiting for fix...
Workaround: this seems to work if you remove DataType="{x:Type …}"
and put x:Key="{ItemContainerTemplateKey {x:Type …}}"
instead.
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 containMenuItems
as their children (a submenu). In one place I set theUsesItemContainerTemplate
-property of the parent totrue
and define anItemContainerTemplate
containing aMenuItem
at the root. As expected the parentsItemContainerGenerator
respects this template and does not generate a menu item around this parents children.After I switched the SDK version in
global.json
from3.0.101
to3.1.100
I noticed that this behavior changed. My submenuitems now are wrapped into an extraMenuItem
.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.