Idk, dev work goin on
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Markup;
|
||||
|
||||
namespace WinWARP.Ui.Converters;
|
||||
|
||||
[MarkupExtensionReturnType(ReturnType = typeof(IValueConverter))]
|
||||
public partial class BoolToVisibilityConverter : MarkupExtension, IValueConverter
|
||||
{
|
||||
public bool IsInverted { get; set; } = false;
|
||||
|
||||
// IValueConverter implementation
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
bool flag = false;
|
||||
if (value is bool boolValue)
|
||||
{
|
||||
flag = boolValue;
|
||||
}
|
||||
|
||||
if (IsInverted)
|
||||
{
|
||||
flag = !flag;
|
||||
}
|
||||
|
||||
return flag ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is Visibility visibility)
|
||||
{
|
||||
bool result = (visibility == Visibility.Visible);
|
||||
return IsInverted ? !result : result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// MarkupExtension override returning self as the instance
|
||||
protected override object ProvideValue()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user