From 471be6b6edab60f7fab066dc4f56c54b0709dc24 Mon Sep 17 00:00:00 2001 From: Bastian Schmidt Date: Sun, 5 Nov 2017 20:04:00 +0100 Subject: [PATCH] Fixes #484 by adding special style for MenutItem with set Description --- Changelog.md | 1 + Fluent.Ribbon.Showcase/TestContent.xaml | 16 +- Fluent.Ribbon/Controls/MenuItem.cs | 2 +- Fluent.Ribbon/Converters/IsNullConverter.cs | 31 ++++ Fluent.Ribbon/Fluent.Ribbon.NET 4.0.csproj | 3 +- Fluent.Ribbon/Fluent.Ribbon.NET 4.5.csproj | 1 + Fluent.Ribbon/Fluent.Ribbon.NET 4.6.2.csproj | 1 + Fluent.Ribbon/Themes/Controls/MenuItem.xaml | 181 +++++++++++++++++-- 8 files changed, 220 insertions(+), 16 deletions(-) create mode 100644 Fluent.Ribbon/Converters/IsNullConverter.cs diff --git a/Changelog.md b/Changelog.md index 316af7b92..393a91c01 100644 --- a/Changelog.md +++ b/Changelog.md @@ -184,6 +184,7 @@ - [#479](../../issues/479) - Bulgarian language (thanks @kalatchev) - [#480](../../issues/480) - Disable Scroll Wheel for tab selection You can control this behavior by using `IsMouseWheelScrollingEnabled` on `Ribbon` + - [#484](../../issues/484) - Add special style/template for MenuItem with set description ## 5.0.2 - [#437](../../issues/437) - "Could not load ControlzEx" diff --git a/Fluent.Ribbon.Showcase/TestContent.xaml b/Fluent.Ribbon.Showcase/TestContent.xaml index 69d49f8b6..8c4a7a906 100644 --- a/Fluent.Ribbon.Showcase/TestContent.xaml +++ b/Fluent.Ribbon.Showcase/TestContent.xaml @@ -1599,8 +1599,20 @@ FocusManager.IsFocusScope="True" CanAddButtonToQuickAccessToolBar="True" ClosePopupOnMouseDown="True"> - - + + + + + + + + + + diff --git a/Fluent.Ribbon/Controls/MenuItem.cs b/Fluent.Ribbon/Controls/MenuItem.cs index 07de67179..76417c6a6 100644 --- a/Fluent.Ribbon/Controls/MenuItem.cs +++ b/Fluent.Ribbon/Controls/MenuItem.cs @@ -119,7 +119,7 @@ public string Description /// Using a DependencyProperty as the backing store for Description. This enables animation, styling, binding, etc... /// public static readonly DependencyProperty DescriptionProperty = - DependencyProperty.Register(nameof(Description), typeof(string), typeof(MenuItem), new PropertyMetadata(StringBoxes.Empty)); + DependencyProperty.Register(nameof(Description), typeof(string), typeof(MenuItem), new PropertyMetadata(default(string))); #endregion diff --git a/Fluent.Ribbon/Converters/IsNullConverter.cs b/Fluent.Ribbon/Converters/IsNullConverter.cs new file mode 100644 index 000000000..450a78a25 --- /dev/null +++ b/Fluent.Ribbon/Converters/IsNullConverter.cs @@ -0,0 +1,31 @@ +namespace Fluent.Converters +{ + using System; + using System.Globalization; + using System.Windows.Data; + + /// + /// Converts null to true and not null to false. + /// + public sealed class IsNullConverter : IValueConverter + { + private static IsNullConverter instance; + + /// + /// A singleton instance for . + /// + public static IsNullConverter Instance => instance ?? (instance = new IsNullConverter()); + + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value == null; + } + + /// + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return Binding.DoNothing; + } + } +} \ No newline at end of file diff --git a/Fluent.Ribbon/Fluent.Ribbon.NET 4.0.csproj b/Fluent.Ribbon/Fluent.Ribbon.NET 4.0.csproj index aafb99821..5e798c07a 100644 --- a/Fluent.Ribbon/Fluent.Ribbon.NET 4.0.csproj +++ b/Fluent.Ribbon/Fluent.Ribbon.NET 4.0.csproj @@ -78,6 +78,7 @@ + @@ -101,12 +102,12 @@ + - diff --git a/Fluent.Ribbon/Fluent.Ribbon.NET 4.5.csproj b/Fluent.Ribbon/Fluent.Ribbon.NET 4.5.csproj index 93e8581e9..d341f2c6e 100644 --- a/Fluent.Ribbon/Fluent.Ribbon.NET 4.5.csproj +++ b/Fluent.Ribbon/Fluent.Ribbon.NET 4.5.csproj @@ -78,6 +78,7 @@ + diff --git a/Fluent.Ribbon/Fluent.Ribbon.NET 4.6.2.csproj b/Fluent.Ribbon/Fluent.Ribbon.NET 4.6.2.csproj index 5c53e5f65..813cd3589 100644 --- a/Fluent.Ribbon/Fluent.Ribbon.NET 4.6.2.csproj +++ b/Fluent.Ribbon/Fluent.Ribbon.NET 4.6.2.csproj @@ -78,6 +78,7 @@ + diff --git a/Fluent.Ribbon/Themes/Controls/MenuItem.xaml b/Fluent.Ribbon/Themes/Controls/MenuItem.xaml index ae9b5816f..e1bdc4d2f 100644 --- a/Fluent.Ribbon/Themes/Controls/MenuItem.xaml +++ b/Fluent.Ribbon/Themes/Controls/MenuItem.xaml @@ -177,7 +177,7 @@ Grid.Column="1" d:LayoutOverrides="Width" RecognizesAccessKey="True" /> - @@ -241,7 +241,7 @@ TargetName="iconImage" Value="0.5" /> + TargetName="checkedImage"> @@ -301,7 +301,7 @@ Grid.Column="1" d:LayoutOverrides="Width" RecognizesAccessKey="True" /> - @@ -475,7 +475,7 @@ TargetName="iconImage" Value="0.5" /> + TargetName="checkedImage"> @@ -556,7 +556,7 @@ Grid.Column="1" d:LayoutOverrides="Width" RecognizesAccessKey="True" /> - @@ -740,7 +740,7 @@ TargetName="iconImage" Value="0.5" /> + TargetName="checkedImage"> @@ -761,6 +761,143 @@ + + + + + \ No newline at end of file