Added in more locking/unlocking logic.
This commit is contained in:
38
Harmonia.WinUI/Converters/BooleanToVisibilityConverter.cs
Normal file
38
Harmonia.WinUI/Converters/BooleanToVisibilityConverter.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Harmonia.WinUI.Converters;
|
||||
|
||||
public class BooleanToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public Visibility TrueValue { get; set; }
|
||||
public Visibility FalseValue { get; set; }
|
||||
|
||||
public BooleanToVisibilityConverter()
|
||||
{
|
||||
TrueValue = Visibility.Visible;
|
||||
FalseValue = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (!(value is bool))
|
||||
return null;
|
||||
|
||||
return (bool)value ? TrueValue : FalseValue;
|
||||
}
|
||||
|
||||
public object? ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (Equals(value, TrueValue))
|
||||
return true;
|
||||
|
||||
if (Equals(value, FalseValue))
|
||||
return false;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user