From 55f8b5104e5d45811e7f0f84a1694f8ac23fde3e Mon Sep 17 00:00:00 2001 From: Yimeng Wu Date: Mon, 15 Jun 2020 00:34:18 +0800 Subject: [PATCH] Remove the need to set an explicit style for a ListView that uses GridView (#114) --- .../ControlPages/ListViewPage.xaml | 3 +- .../Primitives/IsGridViewConverter.cs | 19 +++++ ModernWpf/Styles/ListView.xaml | 71 +++++++++++-------- 3 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 ModernWpf/Controls/Primitives/IsGridViewConverter.cs diff --git a/ModernWpf.SampleApp/ControlPages/ListViewPage.xaml b/ModernWpf.SampleApp/ControlPages/ListViewPage.xaml index 25b8fd32..85ec8569 100644 --- a/ModernWpf.SampleApp/ControlPages/ListViewPage.xaml +++ b/ModernWpf.SampleApp/ControlPages/ListViewPage.xaml @@ -134,10 +134,9 @@ - + diff --git a/ModernWpf/Controls/Primitives/IsGridViewConverter.cs b/ModernWpf/Controls/Primitives/IsGridViewConverter.cs new file mode 100644 index 00000000..b5919c73 --- /dev/null +++ b/ModernWpf/Controls/Primitives/IsGridViewConverter.cs @@ -0,0 +1,19 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace ModernWpf.Controls.Primitives +{ + public class IsGridViewConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value is System.Windows.Controls.GridView; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/ModernWpf/Styles/ListView.xaml b/ModernWpf/Styles/ListView.xaml index cdf66491..8573e64d 100644 --- a/ModernWpf/Styles/ListView.xaml +++ b/ModernWpf/Styles/ListView.xaml @@ -65,7 +65,33 @@ + + - \ No newline at end of file