42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Data;
|
|
using System.Globalization;
|
|
using System.Windows;
|
|
|
|
namespace SudokuWeek4.Models.Converters
|
|
{
|
|
internal class VisibilityValueConverter : IValueConverter
|
|
{
|
|
private static readonly VisibilityValueConverter _instance = new VisibilityValueConverter();
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (!(value is bool) || targetType != typeof(Visibility))
|
|
throw new InvalidCastException();
|
|
|
|
bool visible = (bool)value;
|
|
if (parameter != null)
|
|
visible =! visible;
|
|
|
|
if (visible)
|
|
return Visibility.Visible;
|
|
else
|
|
return Visibility.Hidden;
|
|
}
|
|
|
|
// Create a property to get the instance of the OptionsValue
|
|
public static VisibilityValueConverter Instance
|
|
{
|
|
get { return _instance; }
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|