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

AutomationProperties property not found on object of type MenuItem ( After updating to v4.0.0) #1341

Open
LucaSamarCMA opened this issue Feb 5, 2025 · 6 comments · May be fixed by #1343
Open
Labels
bug Something isn't working

Comments

@LucaSamarCMA
Copy link

LucaSamarCMA commented Feb 5, 2025

Describe the bug

I get this exception after updating to the new release. I don't have this problem with version 4.0.0-rc.3

System.Windows.Data Error: 40 : BindingExpression path error: 'AutomationProperties' property not found on 'object' ''MenuItem' (Name='')'. BindingExpression:Path=AutomationProperties.Name; DataItem='MenuItem' (Name=''); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

To Reproduce

Open the MenuItem

Expected behavior

don't get any xaml error

Screenshots

Image

Image

OS version

Windows 11

.NET version

net9

WPF-UI NuGet version

4.0.0

Additional context

No response

@LucaSamarCMA LucaSamarCMA added the bug Something isn't working label Feb 5, 2025
@snt0
Copy link

snt0 commented Feb 6, 2025

I seem to get this issue when I am creating MenuItems in an ItemsControl.

@timliucode
Copy link

Hi, I encountered the same issue in ui:DropDownButton when using MenuItem.
Additionally, I downloaded and compiled the source code, then ran the WPFUI Gallery, and the same error occurred.

OS version
Windows 11 24H2

.NET version
net8

WPF-UI NuGet version
4.0.0

@JohnTasler
Copy link
Collaborator

Yes, I just noticed this, too. I found the source of the problem, and I'll submit a PR to fix it.

JohnTasler added a commit to JohnTasler/lepoco.wpfui that referenced this issue Feb 9, 2025
Use more efficient `{TemplateBinding}` for `MenuItem` templates, which also fixes the incorrect `{Binding Path}` syntax for attached properties.
@JohnTasler JohnTasler linked a pull request Feb 9, 2025 that will close this issue
1 task
@LucaSamarCMA
Copy link
Author

Hi John, thanks for your help!
I downloaded the code from your fork and I’m no longer seeing the XAML error.
However, it’s still not working as expected. When I click on an item, the menu closes eventhough "StaysOpenOnClick" is set to True, and the corresponding action isn’t triggered

@JohnTasler
Copy link
Collaborator

JohnTasler commented Feb 10, 2025

I'll take a look at that, since I already have a PR for the Binding issues.

Can you provide a ZIP'ed up repro project?

@snt0
Copy link

snt0 commented Feb 10, 2025

When I click on an item, the menu closes eventhough "StaysOpenOnClick" is set to True, and the corresponding action isn’t triggered

I haven't got time to test right now, but I think I fixed an issue with command bindings not working on sub-menu items by settings the TextBlock IsHitTestVisible property (on the newly-added TextBlock that contains the AutomationProperties.Name text) to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants