public override void Dispose() { min.TextChanged -= minTextChanged; max.TextChanged -= maxTextChanged; tickPlacement.Loaded -= tickPlacement_Loaded_1; orientation.Loaded -= orientation_Loaded_1; orientation.SelectionChanged -= orientation_SelectionChanged; snapto.Loaded -= snapto_loaded; snapto.SelectionChanged -= snapsto_OnSelectionChanged; this.orientation.ItemsSource = null; this.tickPlacement.ItemsSource = null; this.snapto.ItemsSource = null; if (Departure != null) { Departure.Dispose(); Departure = null; } if (Arrival != null) { Arrival.Dispose(); Arrival = null; } this.DataContext = null; }