/// <summary> /// Creates an empty flight plan /// </summary> public FlightPlanModel() { #if DEBUG if (DesignHelper.IsInDesignMode()) { Waypoints = new ObservableCollection <WaypointModel>(new List <WaypointModel> { new WaypointModel() { Identifier = "ID1", Latitude = 6.66, Longitude = 12.89 }, new WaypointModel() { Identifier = "ID2", Latitude = -6.66, Longitude = 12.89 }, new WaypointModel() { Identifier = "ID3", Latitude = 6.66, Longitude = -12.89 }, new WaypointModel() { Identifier = "ID4", Latitude = -6.66, Longitude = -12.89 }, }); } #endif }
private static void ValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (DesignHelper.IsInDesignMode()) { return; } bool value = (bool)e.NewValue; if (!value) { return; } FrameworkElement fe = d as FrameworkElement; if (fe == null) { return; } Type type = FindViewModel(fe); if (type == null) { return; } Type interfaceType = typeof(INavigationBase); object vm = null; //没有继承INavigationAware,默认SaveViewModel=false if (interfaceType.IsAssignableFrom(type)) { //查下这个type是否被缓存了 object tmp = ViewModelResposity.Get(type); if (tmp == null) { tmp = Activator.CreateInstance(type); } INavigationBase @base = tmp as INavigationBase; bool isSave = @base.SaveViewModel(); if (isSave) { vm = tmp; } } if (vm == null) { vm = Activator.CreateInstance(type); } ViewModelResposity.Save(vm); fe.DataContext = vm; }
public PlanPointsPartViewModelDesign(bool createParent) : base(null, null, null, null) { if (createParent && DesignHelper.IsInDesignMode()) { var fpvm = new FlightPlanViewModelDesign(this) { FlightPlan = new Model.FlightPlanModel() }; ParentFlightPlan = fpvm; } }