Skip to content

Commit 4f49077

Browse files
committed
Add & Use BoolToVisibilityConverter
1 parent 33aef7e commit 4f49077

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace Flow.Launcher.Plugin.Url.Converters;
7+
8+
[ValueConversion(typeof(bool), typeof(Visibility))]
9+
public class BoolToVisibilityConverter : IValueConverter
10+
{
11+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12+
{
13+
if (value is not bool)
14+
throw new ArgumentException("value should be boolean", nameof(value));
15+
16+
return (bool)value ? Visibility.Visible : Visibility.Collapsed;
17+
}
18+
19+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20+
{
21+
throw new InvalidOperationException();
22+
}
23+
}

Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
mc:Ignorable="d">
1313
<UserControl.Resources>
1414
<converters:InverseBoolConverter x:Key="InverseBoolConverter" />
15+
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
1516
</UserControl.Resources>
1617

1718
<Grid Margin="{StaticResource SettingPanelMargin}">

0 commit comments

Comments
 (0)