dotnet / dotnet/wpf

WPF context menu item style did not apply when manually opening

Open
#5,656 9 comments 1 reaction 2 assignees Claimed by @dipeshmsft View on GitHub
Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/WPF-context-menu-item-style-did-not-appl/1547729)._

---
Hi Team,

We faced the issue "Context menu item style did not apply when manually opening the context menu." In the Dictionary1.xaml and Dictionary2.xaml files, we defined two distinct menu item styles. Initially, we merged the Dicitonary1.xaml style in the main window and we set the IsOpen property value to true. Now if we try to open the context menu by clicking the Left Button, the context menu was displayed but the style was not properly applied.

Please refer to the following screenshot. Here, the applied style didn’t display when left-clicking the button.

! [image.png] (https://aka.ms/dc/image?name=Bb8bfaf08d55f4238837ce25183a8f28f637692206976582707_20211007-214808-image.png&tid=b8bfaf08d55f4238837ce25183a8f28f637692206976582707)

When you right-click the button, the menu item style is applied as expected; it takes the style from the Dictionary1.xaml file.
So when opening the context menu with the left click, the context menu style is not properly applied but it works fine in the right button click. So can you please check this issue on your end and provide a solution?

Please refer to the following screenshot. Here, the applied style properly when right-clicking the button.

! [image.png] (https://aka.ms/dc/image?name=B98bc06b301d649339c4c0e3db36fe648637692207187711203_20211007-214830-image.png&tid=98bc06b301d649339c4c0e3db36fe648637692207187711203)

Replication steps:

1. Run the attached demo

2. Click the ‘Open context menu’ button.

3. Context menu shown but the style didn’t apply.

4. Right-click the ‘Open context menu’ button

5. Now the menu item styles are applied properly(style from Dictionary1.xaml)

Please find the sample below,
[ContextMenuDemo.zip] (https://aka.ms/dc/file?name=Bd1621004bd1848eca8c7987c9d9ccc9d637692208166505326_ContextMenuDemo.zip&tid=d1621004bd1848eca8c7987c9d9ccc9d637692208166505326)

Regards,
Jagadeesan

---
### Original Comments

#### Feedback Bot on 10/8/2021, 00:54 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

#### Jagadeesan Pichaimuthu on 10/14/2021, 05:33 AM:

Hi Team,


Any updated on the above reported issue?

#### Jagadeesan Pichaimuthu on 10/20/2021, 10:37 PM:

Hi Team,


Any updated on the above reported issue?

---
### Original Solutions
(no solutions)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.