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

Adding MenuItems to ContextMenu can cause them to half-function #3506

Closed
grokys opened this issue Feb 3, 2020 · 1 comment · Fixed by #9677
Closed

Adding MenuItems to ContextMenu can cause them to half-function #3506

grokys opened this issue Feb 3, 2020 · 1 comment · Fixed by #9677

Comments

@grokys
Copy link
Member

grokys commented Feb 3, 2020

If we assign a list that doesn't raise change notifications to ContextMenu.Items and then add MenuItems to that list, the items get displayed but they don't display correct hover behavior:

var b = this.FindControl<Border>("b");
var c = b.ContextMenu;
var items = new List<MenuItem>();
var item = new MenuItem { Header = "foo" };

c.Items = items;

// `items` doesn't raise a `CollectionChanged` event
items.Add(item);

Now, it's incorrect to do this, but the result is hard to debug. See if we can do better here either by throwing or by recovering the situation.

@grokys
Copy link
Member Author

grokys commented Feb 3, 2020

The problem here is the ItemsControl.ItemCount is only updated when a collection changed event is fired, so when it comes to select the first item, ItemCount == 0 meaning it thinks index 0 is invalid.

We should fix this in #3388 by moving to ItemsSourceView.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant