fix: Create new instance of ContextMenu on each open
Bugs (fixed): * the volsurface grid context menu items' col/super header names don't stay in sync with clicked cell (the names never change once the menu item becomes visible for the first time)
This commit is contained in:
1 parent
bad6464fe9
commit
9feceb9fdb
2 files changed
+6
-1
No files matched your search
@@ -2,6 +2,7 @@ namespace mbts.ui {
|
||||
using mbts.spark.VolSurface;
|
||||
using mbts.ui.controls;
|
||||
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
class VolSurfaceRowView : DIYGrid.HighPerformanceRow<VolSurfaceRowVM> {
|
||||
@@ -14,6 +15,10 @@ namespace mbts.ui {
|
||||
if (!cell.HasValue || DIYGrid.RowUtils.column_index(_column_layout, cell.Value) < _grid.FrozenColumnCount) {
|
||||
return;
|
||||
}
|
||||
if (TryFindResource("context_menu") is ContextMenu cm) {
|
||||
cm.DataContext = _row.context_menu;
|
||||
ContextMenu = cm;
|
||||
}
|
||||
_row.context_menu.column = (VolSurfaceColumn)cell.Value.column;
|
||||
_row.context_menu.super_header = cell.Value.super_column;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@
|
||||
Rows="{Binding sorted_visible_rows}"
|
||||
IsDragAdornerEnabled="False">
|
||||
<c:DIYGrid.Resources>
|
||||
<ContextMenu x:Key="context_menu" DataContext="{Binding context_menu}">
|
||||
<ContextMenu x:Key="context_menu" x:Shared="False" DataContext="{Binding context_menu}">
|
||||
<MenuItem Header="Settings">
|
||||
<MenuItem.Icon>
|
||||
<Image
|
||||
|
||||
Reference in new issue
Block a user