From 09ac6db6abfc49ffb3f2f7350f4bffa991b256b3 Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Sat, 16 May 2026 14:00:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4MainViewModel=20=E9=87=8C?= =?UTF-8?q?=E7=9A=84=E5=85=BC=E5=AE=B9=E5=8D=A0=E4=BD=8D=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XplorePlane/ViewModels/Main/MainViewModel.cs | 6 +++++ XplorePlane/Views/Main/MainWindow.xaml | 17 ++++++-------- .../Main/NavigationPropertyPanelView.xaml.cs | 22 ++++++++++++++----- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/XplorePlane/ViewModels/Main/MainViewModel.cs b/XplorePlane/ViewModels/Main/MainViewModel.cs index 7ae90db..25d7817 100644 --- a/XplorePlane/ViewModels/Main/MainViewModel.cs +++ b/XplorePlane/ViewModels/Main/MainViewModel.cs @@ -173,6 +173,12 @@ namespace XplorePlane.ViewModels public bool IsUsingLiveDetectorSource => _mainViewportService.CurrentSourceMode == MainViewportSourceMode.LiveDetector; + // Temporary compatibility properties to avoid startup binding errors before + // NavigationPropertyPanelView replaces the inherited DataContext with its own ViewModel. + public BitmapSource CameraImageSource => null; + public string CameraStatusText => string.Empty; + public string CameraPixelCoord => string.Empty; + public string DataRootPath { get => _dataRootPath; diff --git a/XplorePlane/Views/Main/MainWindow.xaml b/XplorePlane/Views/Main/MainWindow.xaml index 6ff2a08..d0ac05b 100644 --- a/XplorePlane/Views/Main/MainWindow.xaml +++ b/XplorePlane/Views/Main/MainWindow.xaml @@ -66,7 +66,7 @@ + > @@ -390,7 +390,7 @@ - + @@ -415,24 +415,22 @@ - + @@ -455,11 +453,10 @@ + IsEnabled="True"> diff --git a/XplorePlane/Views/Main/NavigationPropertyPanelView.xaml.cs b/XplorePlane/Views/Main/NavigationPropertyPanelView.xaml.cs index 39a7b9c..dd3c414 100644 --- a/XplorePlane/Views/Main/NavigationPropertyPanelView.xaml.cs +++ b/XplorePlane/Views/Main/NavigationPropertyPanelView.xaml.cs @@ -13,19 +13,31 @@ namespace XplorePlane.Views public NavigationPropertyPanelView() { InitializeComponent(); + ResolveViewModel(); Loaded += OnLoaded; } private void OnLoaded(object sender, RoutedEventArgs e) { - if (DataContext is NavigationPropertyPanelViewModel) return; + ResolveViewModel(); + } + + private void ResolveViewModel() + { + if (DataContext is NavigationPropertyPanelViewModel viewModel) + { + _viewModel = viewModel; + return; + } var bootstrapper = AppBootstrapper.Instance; - if (bootstrapper != null) + if (bootstrapper == null) { - _viewModel = bootstrapper.Container.Resolve(); - DataContext = _viewModel; + return; } + + _viewModel = bootstrapper.Container.Resolve(); + DataContext = _viewModel; } /// @@ -53,4 +65,4 @@ namespace XplorePlane.Views } } } -} \ No newline at end of file +}