开发者

WPF: Context Menu dissapears after item update in my GridView

开发者 https://www.devze.com 2023-02-22 11:48 出处:网络
so, I have this ListView in grid mode. I am dynamically updating it using a CollectionView. now, the problem I have is that when I open a context menu by 开发者_Go百科right clicking on an item in my g

so, I have this ListView in grid mode. I am dynamically updating it using a CollectionView. now, the problem I have is that when I open a context menu by 开发者_Go百科right clicking on an item in my grid the context menu closes after the item updates--now, it is not a new item but it is the same item. Does anyone have any ideas on how I can make the contet menu stay open after the item updates?

[Edit]

The grid is part of a public safety application that updates in near real-time. so the items are periodically added, removed, and updated. If we right-click on an item to open the context menu and an update occurs before I can close it--even if the particular item does not change in any way--the context menu closes. The desired behavior is for the context menu to remain open.


If you could supply your XAML that would help, but my guess is that you have defined the context menu on the ListViewItem element and that the menu closes because the whole ListViewItem is regenerated or replaced by WPF.

Perhaps you can define the context menu on the ListView instead? You will have to update your commands and get the selected item from the list when executing, since the context will no longer be a specific item.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号