public TransitMapPage() { this.InitializeComponent(); ChangeViewCommand = new WeakRelayCommand(ChangeViewCommand_Execute); NavigateToStopPageCommand = new WeakRelayCommand(NavigateToStopPageCommand_Execute); MainMap.AddIns.Add(StopsAddIn); MainMap.AddIns.Add(StopDetailsAddIn); MainMap.AddIns.Add(new CurrentLocationAddIn()); VM = new TransitMapPageUwpViewModel(Cache) { Title = "Transit Map" }; DataContext = VM; //DatabaseManager.Initialize(null); //TransitStop.SqlProvider.CreateTable(DatabaseManager.MemoryDatabase, true); //MainMap.StopsSource = Stops; StopsAddIn.StopsSource = VM.ShownStops; StopDetailsAddIn.SelectedStopsSource = VM.SelectedStops; VM.BindToDependencyObject(StopsAddIn, ShownStopsAddIn.StopsClickedCommandProperty, "StopsClickedCommand"); VM.BindToDependencyObject(StopsAddIn, ShownStopsAddIn.StopSizeProperty, "ShownStopSize"); VM.BindToControl(MainMap, TransitMap.AreaDelayProperty, "Area", true); VM.BindToControl(MainMap, TransitMap.ZoomLevelDelayProperty, "ZoomLevel", true); VM.BindToDependencyObject(StopDetailsAddIn, StopDetailsPopupAddIn.HasSelectedStopsProperty, "HasSelectedStops", true); VM.BindToControl(this, CanGoBackProperty, "CanGoBack"); VM.ChangeViewBackCommand = ChangeViewCommand; VM.NavigateToStopPageBackCommand = NavigateToStopPageCommand; //SetBinding(CanGoBackProperty, new Binding() { Source = MainMap, Path = new PropertyPath("CanGoBack"), Mode = BindingMode.OneWay }); }
public TransitMapPageViewModel(MemoryCache cache) { StopsClickedCommand = new WeakRelayCommand(StopsClickedCommand_Execute); NavigateToStopPageCommand = new RelayCommand(NavigateToStopPageCommand_Execute); CenterOnCurrentLocationCommand = new RelayCommand(CenterOnCurrentLocation_Execute); RefreshCommand = new RelayCommand(Refresh_Execute); SearchCommand = new RelayCommand(Search_Execute, obj => (obj?.ToString()?.Length ?? 0) > 4); GoToLocationCommand = new RelayCommand(GoToLocation_Execute); NavigatedToCommand = new RelayCommand(OnNavigatedTo); CancelRefreshCommand = new RelayCommand((obj) => { TokenSource.Cancel(); TokenSource = new CancellationTokenSource(); }); Cache = cache; SelectedStops.CollectionChanged += SelectedStops_CollectionChanged; NetworkManagerBase.Instance.NetworkTypeChanged += (s, e) => LoadFromSettings(); //*MemoryLeak*!!! Temporary LoadFromSettings(); }