punker76 on develop
Update MessageDialog.cs Fix De… Merge pull request #4247 from c… (compare)
punker76 on develop
Updated readme with some additi… Merge pull request #4296 from n… (compare)
MetroWindow
or normal Window
ClearTextButton
on a ComboBox and only show it when an item is selected. For TextBoxes i use this binding which works like a charm mah:TextBoxHelper.ClearTextButton="{Binding Path=(mah:TextBoxHelper.HasText), RelativeSource={RelativeSource Mode=Self}}"
but not for a ComboBox. Is there an easy way to modify this OR do i have to apply a custom style?
@TripleNico You can get this by using this converter (works only with non editable ComboBox)
[ValueConversion(typeof(object), typeof(bool))]
public sealed class IsNotNullConverter : IValueConverter
{
/// <summary>
/// Gets a static default instance of <see cref="IsNotNullConverter "/>.
/// </summary>
public static readonly IsNotNullConverter Instance = new();
public object? Convert(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
{
return value is not null;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
{
return Binding.DoNothing;
}
}
usage:
<ComboBox Width="200"
Margin="{StaticResource ControlMargin}"
mah:TextBoxHelper.ClearTextButton="{Binding Path=SelectedItem, RelativeSource={RelativeSource Mode=Self}, Converter={x:Static local:IsNotNullConverter.Instance}}"
mah:TextBoxHelper.Watermark="Please select an item..."
SelectedIndex="0">
<ComboBoxItem Content="Item 1" />
<ComboBoxItem Content="Item 2" />
<ComboBoxItem Content="Very long Item 3 for MahApps.Metro" />
<ComboBoxItem Content="Item 4" />
</ComboBox>
CustomDialog
instead with a custom view inside, see: https://github.com/MahApps/MahApps.Metro/blob/develop/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/CustomDialogExample.xaml