diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ComboBoxPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ComboBoxPage.xaml index 10a4add10..73e3d63b3 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ComboBoxPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ComboBoxPage.xaml @@ -62,5 +62,16 @@ ItemsSource="{Binding ViewModel.ComboBoxFontSizes, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ComboBoxPage}, Mode=OneWay}" SelectedIndex="0" /> + + + + diff --git a/src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml b/src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml index c2ccdb78e..69ed20a80 100644 --- a/src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml +++ b/src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml @@ -14,8 +14,11 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:Wpf.Ui.Controls" + xmlns:converters="clr-namespace:Wpf.Ui.Converters" xmlns:system="clr-namespace:System;assembly=System.Runtime"> + + 10,8,10,8 1,1,1,1 0,0,0,2 @@ -181,10 +184,10 @@ + @@ -315,6 +329,10 @@ From="0" To="180" Duration="00:00:00.167" /> + + + + +/// Used to extend the stock WPF ComboBox control. +/// +public static class ComboBoxHelper +{ + public static readonly DependencyProperty PlaceholderProperty = + DependencyProperty.RegisterAttached( + "Placeholder", + typeof(object), + typeof(ComboBoxHelper), + new PropertyMetadata(null)); + + public static object GetPlaceholder(ComboBox control) => control.GetValue(PlaceholderProperty); + + public static void SetPlaceholder(ComboBox control, object value) => control.SetValue(PlaceholderProperty, value); +} diff --git a/src/Wpf.Ui/Converters/NullToVisibilityConverter.cs b/src/Wpf.Ui/Converters/NullToVisibilityConverter.cs index fbbbbb4c9..8935727b2 100644 --- a/src/Wpf.Ui/Converters/NullToVisibilityConverter.cs +++ b/src/Wpf.Ui/Converters/NullToVisibilityConverter.cs @@ -3,6 +3,7 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System.Windows; using System.Windows.Data; namespace Wpf.Ui.Converters; @@ -11,7 +12,25 @@ internal class NullToVisibilityConverter : IValueConverter { public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - return value is null ? Visibility.Collapsed : Visibility.Visible; + if (value is string str) + { + value = string.IsNullOrEmpty(str); + } + else if (value == null) + { + value = true; + } + else + { + value = false; + } + + if (parameter is "negate") + { + return (bool)value ? Visibility.Visible : Visibility.Collapsed; + } + + return (bool)value ? Visibility.Collapsed : Visibility.Visible; } public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)