整理控件库
This commit is contained in:
@@ -3,86 +3,17 @@
|
||||
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
|
||||
// All Rights Reserved.
|
||||
|
||||
using WPFluent.Controls;
|
||||
using WPFluent.Gallery.Services.Contracts;
|
||||
using WPFluent.Gallery.ViewModels.Windows;
|
||||
using WPFluent.Gallery.Views.Pages;
|
||||
|
||||
namespace WPFluent.Gallery.Views.Windows;
|
||||
|
||||
public partial class MainWindow : IWindow
|
||||
public partial class MainWindow
|
||||
{
|
||||
public MainWindow(
|
||||
MainWindowViewModel viewModel,
|
||||
INavigationService navigationService,
|
||||
IServiceProvider serviceProvider,
|
||||
ISnackbarService snackbarService,
|
||||
IContentDialogService contentDialogService
|
||||
)
|
||||
public MainWindow()
|
||||
{
|
||||
//适应当前系统的主题
|
||||
//Appearance.SystemThemeWatcher.Watch(this);
|
||||
|
||||
ViewModel = viewModel;
|
||||
DataContext = this;
|
||||
|
||||
ViewModel = new MainWindowViewModel();
|
||||
DataContext = ViewModel;
|
||||
InitializeComponent();
|
||||
|
||||
snackbarService.SetSnackbarPresenter(SnackbarPresenter);
|
||||
navigationService.SetNavigationControl(NavigationView);
|
||||
contentDialogService.SetDialogHost(RootContentDialog);
|
||||
}
|
||||
|
||||
public MainWindowViewModel ViewModel { get; }
|
||||
|
||||
private bool _isUserClosedPane;
|
||||
|
||||
private bool _isPaneOpenedOrClosedFromCode;
|
||||
|
||||
private void OnNavigationSelectionChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is not WPFluent.Controls.NavigationView navigationView)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NavigationView.SetCurrentValue(
|
||||
NavigationView.HeaderVisibilityProperty,
|
||||
navigationView.SelectedItem?.TargetPageType != typeof(DashboardPage)
|
||||
? Visibility.Visible
|
||||
: Visibility.Collapsed
|
||||
);
|
||||
}
|
||||
|
||||
private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
if (_isUserClosedPane)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isPaneOpenedOrClosedFromCode = true;
|
||||
NavigationView.SetCurrentValue(NavigationView.IsPaneOpenProperty, e.NewSize.Width > 1200);
|
||||
_isPaneOpenedOrClosedFromCode = false;
|
||||
}
|
||||
|
||||
private void NavigationView_OnPaneOpened(NavigationView sender, RoutedEventArgs args)
|
||||
{
|
||||
if (_isPaneOpenedOrClosedFromCode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isUserClosedPane = false;
|
||||
}
|
||||
|
||||
private void NavigationView_OnPaneClosed(NavigationView sender, RoutedEventArgs args)
|
||||
{
|
||||
if (_isPaneOpenedOrClosedFromCode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isUserClosedPane = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user