diff --git a/src/Wpf.Ui.Gallery/App.xaml b/src/Wpf.Ui.Gallery/App.xaml index 1c2e59256..1088a5938 100644 --- a/src/Wpf.Ui.Gallery/App.xaml +++ b/src/Wpf.Ui.Gallery/App.xaml @@ -7,6 +7,7 @@ xmlns:syntax="http://schemas.lepo.co/wpfui/2022/xaml/syntax" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" DispatcherUnhandledException="OnDispatcherUnhandledException" + xmlns:system="clr-namespace:System;assembly=mscorlib" Exit="OnExit" Startup="OnStartup"> diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml index 91d6247fe..d13e0ae02 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ButtonPage.xaml @@ -94,6 +94,50 @@ Icon="{ui:SymbolIcon Fluent24}" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/// Represents an icon that uses an DrawingBrush as its content. +/// +public class DrawingBrushIcon : IconElement +{ + /// + /// Gets or sets + /// + public DrawingBrush Icon + { + get { return (DrawingBrush)GetValue(IconProperty); } + set { SetValue(IconProperty, value); } + } + + /// Identifies the dependency property. + public static readonly DependencyProperty IconProperty = DependencyProperty.Register( + nameof(Icon), + typeof(DrawingBrush), + typeof(DrawingBrushIcon), + new PropertyMetadata(default(DrawingBrush), OnIconChanged)); + + private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var self = (DrawingBrushIcon)d; + if (self.Border is null) + return; + + self.Border.Background = e.NewValue as DrawingBrush; + } + + /// + /// Gets or sets + /// + public double Size + { + get { return (double)GetValue(SizeProperty); } + set { SetValue(SizeProperty, value); } + } + + /// Identifies the dependency property. + public static readonly DependencyProperty SizeProperty = DependencyProperty.Register( + nameof(Size), + typeof(double), + typeof(DrawingBrushIcon), + new PropertyMetadata(16.0, OnIconSizeChanged)); + + private static void OnIconSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var self = (DrawingBrushIcon)d; + if (self.Border is null) + { + return; + } + + if (double.TryParse(e.NewValue?.ToString(), out double dblValue)) + { + self.Border.Width = dblValue; + self.Border.Height = dblValue; + } + } + + protected Border? Border; + + protected override UIElement InitializeChildren() + { + Border = new Border() + { + HorizontalAlignment = HorizontalAlignment.Stretch, + Background = Icon, + Width = Size, + Height = Size + }; + + Viewbox viewbox = new Viewbox(); + viewbox.Child = Border; + + return viewbox; + } +} diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewCompact.xaml b/src/Wpf.Ui/Controls/NavigationView/NavigationViewCompact.xaml index 29b31e856..6793d420c 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewCompact.xaml +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewCompact.xaml @@ -17,8 +17,8 @@ - + - - + + + @@ -211,7 +213,7 @@ - + @@ -307,6 +309,8 @@ Grid.Row="0" Margin="0,5,0,5" HorizontalAlignment="Left" + Width="{DynamicResource PaneLeftButtonWidth}" + Height="{DynamicResource PaneLeftButtonHeight}" IsEnabled="{TemplateBinding IsBackEnabled}" Style="{StaticResource BasePaneButtonStyle}" Visibility="{TemplateBinding IsBackButtonVisible, @@ -316,20 +320,30 @@ - + + + + + + + - - - - - - - + + + + + + + + @@ -461,7 +475,7 @@ Storyboard.TargetName="PaneGrid" Storyboard.TargetProperty="Width" From="{TemplateBinding OpenPaneLength}" - To="40" + To="{DynamicResource PaneLeftButtonWidth}" Duration="0:0:.16" /> @@ -474,6 +488,7 @@ + @@ -481,6 +496,7 @@ + diff --git a/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml b/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml index 5c396e733..cd2e6a63b 100644 --- a/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml +++ b/src/Wpf.Ui/Controls/NavigationView/NavigationViewConstants.xaml @@ -4,6 +4,11 @@ xmlns:converters="clr-namespace:Wpf.Ui.Converters" xmlns:system="clr-namespace:System;assembly=mscorlib"> + 12 + 16 + 40 + 40 + 24 40 40 @@ -11,6 +16,8 @@ 60 12 1,1,1,1 + + diff --git a/src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml b/src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml index b655bdf11..e62897aa1 100644 --- a/src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml +++ b/src/Wpf.Ui/Controls/TextBlock/TextBlock.xaml @@ -14,7 +14,7 @@ - + diff --git a/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs b/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs new file mode 100644 index 000000000..a1de2ce49 --- /dev/null +++ b/src/Wpf.Ui/Markup/DrawingBrushIconExtension.cs @@ -0,0 +1,38 @@ +// 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.Windows.Markup; +using Wpf.Ui.Controls; + +namespace Wpf.Ui.Markup; + +[ContentProperty(nameof(Icon))] +[MarkupExtensionReturnType(typeof(DrawingBrushIcon))] +public class DrawingBrushIconExtension : MarkupExtension +{ + public DrawingBrushIconExtension(DrawingBrush icon) + { + Icon = icon; + } + + public DrawingBrushIconExtension(DrawingBrush icon, double size) + : this(icon) + { + Size = size; + } + + [ConstructorArgument("icon")] + public DrawingBrush Icon { get; set; } + + [ConstructorArgument("size")] + public double Size { get; set; } = 16; + + public override object ProvideValue(IServiceProvider serviceProvider) + { + var drawingBrushIcon = new DrawingBrushIcon { Icon = Icon, Size = Size }; + + return drawingBrushIcon; + } +}