From e58dd72f90e42667ad91e7451c03a4e8a20248b3 Mon Sep 17 00:00:00 2001 From: syneffort Date: Tue, 4 Jul 2023 17:49:43 +0900 Subject: [PATCH] listbox groupage --- .../Converter/AgeToRangeConverter.cs | 27 +++++++++++++++++ PacticeSolution/ListSample/ListSample.csproj | 1 + PacticeSolution/ListSample/MainWindow.xaml | 29 +++++++++++++++++-- PacticeSolution/ListSample/MainWindow.xaml.cs | 13 ++++++++- 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 PacticeSolution/ListSample/Converter/AgeToRangeConverter.cs diff --git a/PacticeSolution/ListSample/Converter/AgeToRangeConverter.cs b/PacticeSolution/ListSample/Converter/AgeToRangeConverter.cs new file mode 100644 index 0000000..afb24a9 --- /dev/null +++ b/PacticeSolution/ListSample/Converter/AgeToRangeConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace ListSample.Converter +{ + [ValueConversion(typeof(int), typeof(string))] + internal class AgeToRangeConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + return null; + + return (int)value >= 40 ? "OB Group" : "YB Group"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} diff --git a/PacticeSolution/ListSample/ListSample.csproj b/PacticeSolution/ListSample/ListSample.csproj index 2c18da2..9530d10 100644 --- a/PacticeSolution/ListSample/ListSample.csproj +++ b/PacticeSolution/ListSample/ListSample.csproj @@ -55,6 +55,7 @@ MSBuild:Compile Designer + True True diff --git a/PacticeSolution/ListSample/MainWindow.xaml b/PacticeSolution/ListSample/MainWindow.xaml index f55b15a..938b650 100644 --- a/PacticeSolution/ListSample/MainWindow.xaml +++ b/PacticeSolution/ListSample/MainWindow.xaml @@ -33,7 +33,7 @@