Properly Dispose of the OrderBookVM when the popup closes
This commit is contained in:
1 parent
e7b9c3e228
commit
26dfd89d6c
1 file changed
+7
-2
@@ -128,17 +128,22 @@ namespace mbts.spark {
|
||||
var curr_order = b.DataContext as LadderOrderVM;
|
||||
if (e.ChangedButton == MouseButton.Middle) {
|
||||
// create the new popup window in here
|
||||
|
||||
var view = new MiniOrderBookView(order.orderbook_vm);
|
||||
var obvm = order.orderbook_vm;
|
||||
var view = new MiniOrderBookView(obvm);
|
||||
var popup = new System.Windows.Controls.Primitives.Popup();
|
||||
// we only keep the obvm around assigned to the DataContext so that we can
|
||||
// properly Dispose of it later when the popup is closed.
|
||||
popup.DataContext = obvm;
|
||||
popup.Child = view;
|
||||
popup.StaysOpen = false;
|
||||
popup.PlacementTarget = popup_placement_target;
|
||||
popup.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
|
||||
popup.VerticalOffset = 5;
|
||||
popup.IsOpen = true;
|
||||
popup.Closed += (sender, event_args) => (popup.DataContext as IDisposable)?.Dispose();
|
||||
b.Popup = popup;
|
||||
|
||||
|
||||
// close context menu after command executed
|
||||
//if (curr_order != null) {
|
||||
// Action command_executed = null;
|
||||
|
||||
Reference in new issue
Block a user