diff --git a/src/Wpf.Ui.Demo/Views/Windows/ExperimentalWindow.xaml b/src/Wpf.Ui.Demo/Views/Windows/ExperimentalWindow.xaml index f8b8688ca..65cfe0489 100644 --- a/src/Wpf.Ui.Demo/Views/Windows/ExperimentalWindow.xaml +++ b/src/Wpf.Ui.Demo/Views/Windows/ExperimentalWindow.xaml @@ -24,18 +24,20 @@ - - + - - + + - - - - - - + + + + + - - - - - - - - - - - - - diff --git a/src/Wpf.Ui.Demo/Views/Windows/TaskManagerWindow.xaml.cs b/src/Wpf.Ui.Demo/Views/Windows/TaskManagerWindow.xaml.cs index 0a1df2013..ffa70d476 100644 --- a/src/Wpf.Ui.Demo/Views/Windows/TaskManagerWindow.xaml.cs +++ b/src/Wpf.Ui.Demo/Views/Windows/TaskManagerWindow.xaml.cs @@ -12,15 +12,9 @@ namespace Wpf.Ui.Demo.Views.Windows; /// public partial class TaskManagerWindow { - public TaskManagerViewModel ViewModel - { - get; - } - public TaskManagerWindow(TaskManagerViewModel viewModel) { - ViewModel = viewModel; - DataContext = this; + DataContext = viewModel; InitializeComponent(); } diff --git a/src/Wpf.Ui/Controls/NavigationCompact.cs b/src/Wpf.Ui/Controls/NavigationCompact.cs deleted file mode 100644 index e81ea10c1..000000000 --- a/src/Wpf.Ui/Controls/NavigationCompact.cs +++ /dev/null @@ -1,68 +0,0 @@ -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. -// Copyright (C) Leszek Pomianowski and WPF UI Contributors. -// All Rights Reserved. - -using System; -using System.ComponentModel; -using System.Drawing; -using System.Windows; - -namespace Wpf.Ui.Controls; - -/// -/// Modern navigation styled similar to the Task Manager in Windows 11. -/// -[ToolboxItem(true)] -[ToolboxBitmap(typeof(NavigationCompact), "NavigationCompact.bmp")] -public class NavigationCompact : Wpf.Ui.Controls.Navigation.NavigationBase -{ - /// - /// Property for . - /// - public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register( - nameof(IsExpanded), - typeof(bool), typeof(NavigationCompact), - new PropertyMetadata(false)); - - /// - /// Property for . - /// - public static readonly DependencyProperty TemplateButtonCommandProperty = - DependencyProperty.Register(nameof(TemplateButtonCommand), - typeof(Common.IRelayCommand), typeof(NavigationCompact), new PropertyMetadata(null)); - - /// - /// Gets or sets a value indicating whether the menu is expanded. - /// - public bool IsExpanded - { - get => (bool)GetValue(IsExpandedProperty); - set => SetValue(IsExpandedProperty, value); - } - - /// - /// Command triggered after clicking the button. - /// - public Common.IRelayCommand TemplateButtonCommand => (Common.IRelayCommand)GetValue(TemplateButtonCommandProperty); - - /// - /// Creates new instance and sets default . - /// - public NavigationCompact() : base() => - SetValue(TemplateButtonCommandProperty, new Common.RelayCommand(o => Button_OnClick(this, o))); - - private void Button_OnClick(object sender, object parameter) - { - if (parameter == null) - return; - - string param = parameter as string ?? String.Empty; - -#if DEBUG - System.Diagnostics.Debug.WriteLine($"INFO: {typeof(NavigationCompact)} button clicked with param: {param}", "Wpf.Ui.NavigationCompact"); -#endif - if (param == "hamburger") - IsExpanded = !IsExpanded; - } -} diff --git a/src/Wpf.Ui/Controls/NavigationFluent.bmp b/src/Wpf.Ui/Controls/NavigationFluent.bmp deleted file mode 100644 index 930c735ad..000000000 Binary files a/src/Wpf.Ui/Controls/NavigationFluent.bmp and /dev/null differ diff --git a/src/Wpf.Ui/Controls/NavigationFluent.cs b/src/Wpf.Ui/Controls/NavigationFluent.cs index eb7c88a87..44d9364dc 100644 --- a/src/Wpf.Ui/Controls/NavigationFluent.cs +++ b/src/Wpf.Ui/Controls/NavigationFluent.cs @@ -3,8 +3,10 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System; using System.ComponentModel; using System.Drawing; +using System.Windows; namespace Wpf.Ui.Controls; @@ -15,5 +17,69 @@ namespace Wpf.Ui.Controls; [ToolboxBitmap(typeof(NavigationFluent), "NavigationFluent.bmp")] public class NavigationFluent : Wpf.Ui.Controls.Navigation.NavigationBase { - // XAML + /// + /// Property for . + /// + public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register( + nameof(IsExpanded), + typeof(bool), typeof(NavigationFluent), + new PropertyMetadata(true)); + + /// + /// Property for . + /// + public static readonly DependencyProperty IsExpandButtonVisibleProperty = DependencyProperty.Register( + nameof(IsExpandButtonVisible), + typeof(bool), typeof(NavigationFluent), + new PropertyMetadata(false)); + + /// + /// Property for . + /// + public static readonly DependencyProperty TemplateButtonCommandProperty = + DependencyProperty.Register(nameof(TemplateButtonCommand), + typeof(Common.IRelayCommand), typeof(NavigationFluent), new PropertyMetadata(null)); + + /// + /// Gets or sets a value indicating whether the menu is expanded. + /// + public bool IsExpanded + { + get => (bool)GetValue(IsExpandedProperty); + set => SetValue(IsExpandedProperty, value); + } + + /// + /// TODO + /// + public bool IsExpandButtonVisible + { + get => (bool)GetValue(IsExpandButtonVisibleProperty); + set => SetValue(IsExpandButtonVisibleProperty, value); + } + + /// + /// Command triggered after clicking the button. + /// + public Common.IRelayCommand TemplateButtonCommand => (Common.IRelayCommand)GetValue(TemplateButtonCommandProperty); + + /// + /// Creates new instance and sets default . + /// + public NavigationFluent() : base() => + SetValue(TemplateButtonCommandProperty, new Common.RelayCommand(o => Button_OnClick(this, o))); + + private void Button_OnClick(object sender, object parameter) + { + if (parameter == null) + return; + + string param = parameter as string ?? String.Empty; + +#if DEBUG + System.Diagnostics.Debug.WriteLine($"INFO: {typeof(NavigationFluent)} button clicked with param: {param}", "Wpf.Ui.NavigationFluent"); +#endif + if (param == "hamburger") + IsExpanded = !IsExpanded; + } } diff --git a/src/Wpf.Ui/Controls/NavigationView.cs b/src/Wpf.Ui/Controls/NavigationView.cs index 855dddee4..3cc508e5b 100644 --- a/src/Wpf.Ui/Controls/NavigationView.cs +++ b/src/Wpf.Ui/Controls/NavigationView.cs @@ -3,68 +3,114 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +#nullable enable using System.Windows; using System.Windows.Controls; -using Wpf.Ui.Common; using Wpf.Ui.Controls.Interfaces; +using Wpf.Ui.Controls.Navigation; namespace Wpf.Ui.Controls; /// /// Ready navigation that includes a control, and . /// -[TemplatePart(Name = "PART_Navigation", Type = typeof(Wpf.Ui.Controls.Navigation.NavigationBase))] -[TemplatePart(Name = "PART_Breadcrumb", Type = typeof(Wpf.Ui.Controls.Breadcrumb))] -[TemplatePart(Name = "PART_Frame", Type = typeof(System.Windows.Controls.Frame))] +[TemplatePart(Name = "PART_BackButton", Type = typeof(NavigationBackButton))] +[TemplatePart(Name = "PART_Breadcrumb", Type = typeof(Breadcrumb))] +[TemplatePart(Name = "PART_Frame", Type = typeof(Frame))] public class NavigationView : System.Windows.Controls.Control { - /// - /// Template element represented by the PART_Popup name. - /// - private const string ElementNavigation = "PART_Navigation"; + public static readonly DependencyProperty NavigationProperty = DependencyProperty.Register(nameof(Navigation), + typeof(INavigation), typeof(NavigationView), + new PropertyMetadata(null)); - /// - /// Template element represented by the PART_Popup name. - /// - private const string ElementBreadcrumb = "PART_Breadcrumb"; + public static readonly DependencyProperty BreadcrumbMarginProperty = DependencyProperty.Register(nameof(BreadcrumbMargin), + typeof(Thickness), typeof(NavigationView), + new PropertyMetadata(new Thickness(18, 18, 18, 18))); - /// - /// Template element represented by the PART_Popup name. - /// - private const string ElementFrame = "PART_Frame"; + public static readonly DependencyProperty FrameBorderMarginProperty = DependencyProperty.Register(nameof(FrameBorderMargin), + typeof(Thickness), typeof(NavigationView), + new PropertyMetadata(new Thickness(0, 0, 0, 0))); - public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(nameof(Type), - typeof(NavigationType), typeof(NavigationView), - new PropertyMetadata(NavigationType.Compact)); + public static readonly DependencyProperty FramePaddingProperty = DependencyProperty.Register(nameof(FramePadding), + typeof(Thickness), typeof(NavigationView), + new PropertyMetadata(new Thickness(0, 0, 0, 0))); - /// - /// Navigation control. - /// - public INavigation Navigation { get; protected set; } + public static readonly DependencyProperty IsBackButtonVisibleProperty = DependencyProperty.Register(nameof(IsBackButtonVisible), + typeof(bool), typeof(NavigationView), + new PropertyMetadata(false)); + + public static readonly DependencyProperty IsBreadcrumbVisibleProperty = DependencyProperty.Register(nameof(IsBreadcrumbVisible), + typeof(bool), typeof(NavigationView), + new PropertyMetadata(false)); + + public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), + typeof(object), typeof(NavigationView), + new PropertyMetadata(null)); + + public INavigation Navigation + { + get => (INavigation)GetValue(NavigationProperty); + set => SetValue(NavigationProperty, value); + } + + public Thickness BreadcrumbMargin + { + get => (Thickness)GetValue(BreadcrumbMarginProperty); + set => SetValue(BreadcrumbMarginProperty, value); + } + + public Thickness FrameBorderMargin + { + get => (Thickness)GetValue(FrameBorderMarginProperty); + set => SetValue(FrameBorderMarginProperty, value); + } + + public Thickness FramePadding + { + get => (Thickness)GetValue(FramePaddingProperty); + set => SetValue(FramePaddingProperty, value); + } + + public bool IsBackButtonVisible + { + get => (bool)GetValue(IsBackButtonVisibleProperty); + set => SetValue(IsBackButtonVisibleProperty, value); + } + + public bool IsBreadcrumbVisible + { + get => (bool)GetValue(IsBreadcrumbVisibleProperty); + set => SetValue(IsBreadcrumbVisibleProperty, value); + } + + public object? Content + { + get => GetValue(ContentProperty); + set => SetValue(ContentProperty, value); + } /// - /// Navigation breadcrumb. + /// Back button /// - public Breadcrumb Breadcrumb { get; protected set; } + public NavigationBackButton BackButton { get; private set; } = null!; /// /// Navigation frame /// - public Frame Frame { get; protected set; } + public Frame Frame { get; protected set; } = null!; - public NavigationType Type - { - get => (NavigationType)GetValue(TypeProperty); - set => SetValue(TypeProperty, value); - } + /// + /// Breadcrumb + /// + public Breadcrumb Breadcrumb { get; private set; } = null!; - /// public override void OnApplyTemplate() { base.OnApplyTemplate(); + BackButton = (NavigationBackButton)GetTemplateChild("PART_BackButton")!; + Frame = (Frame)GetTemplateChild("PART_Frame")!; + Breadcrumb = (Breadcrumb)GetTemplateChild("PART_Breadcrumb")!; - Navigation = GetTemplateChild(ElementNavigation) as INavigation; - Breadcrumb = GetTemplateChild(ElementBreadcrumb) as Breadcrumb; - Frame = GetTemplateChild(ElementFrame) as Frame; + Navigation.Frame = Frame; } } diff --git a/src/Wpf.Ui/Styles/Controls/NavigationCompact.xaml b/src/Wpf.Ui/Styles/Controls/NavigationCompact.xaml deleted file mode 100644 index 9f25a1c0e..000000000 --- a/src/Wpf.Ui/Styles/Controls/NavigationCompact.xaml +++ /dev/null @@ -1,408 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/Wpf.Ui/Styles/Controls/NavigationFluent.xaml b/src/Wpf.Ui/Styles/Controls/NavigationFluent.xaml index 2105adc07..56ecc1de1 100644 --- a/src/Wpf.Ui/Styles/Controls/NavigationFluent.xaml +++ b/src/Wpf.Ui/Styles/Controls/NavigationFluent.xaml @@ -8,16 +8,160 @@ + xmlns:controls="clr-namespace:Wpf.Ui.Controls" + xmlns:navigation="clr-namespace:Wpf.Ui.Controls.Navigation"> - + + + + diff --git a/src/Wpf.Ui/Styles/Controls/NavigationView.xaml b/src/Wpf.Ui/Styles/Controls/NavigationView.xaml index 7453eb9a9..4fe225a48 100644 --- a/src/Wpf.Ui/Styles/Controls/NavigationView.xaml +++ b/src/Wpf.Ui/Styles/Controls/NavigationView.xaml @@ -8,84 +8,73 @@ + xmlns:controls="clr-namespace:Wpf.Ui.Controls" + xmlns:navigation="clr-namespace:Wpf.Ui.Controls.Navigation"> \ No newline at end of file diff --git a/src/Wpf.Ui/Styles/Wpf.Ui.xaml b/src/Wpf.Ui/Styles/Wpf.Ui.xaml index f1258ed10..ed5d3a8b1 100644 --- a/src/Wpf.Ui/Styles/Wpf.Ui.xaml +++ b/src/Wpf.Ui/Styles/Wpf.Ui.xaml @@ -29,7 +29,6 @@ - diff --git a/src/Wpf.Ui/Wpf.Ui.csproj b/src/Wpf.Ui/Wpf.Ui.csproj index c723d1d40..6de2d93f0 100644 --- a/src/Wpf.Ui/Wpf.Ui.csproj +++ b/src/Wpf.Ui/Wpf.Ui.csproj @@ -86,7 +86,6 @@ - @@ -124,7 +123,6 @@ -