a boolean to abject converter
This commit is contained in:
parent
6e33f995c1
commit
aab8e78d22
1 changed files with 29 additions and 0 deletions
29
BookAStar/BookAStar/Converters/BooleanToObjectConverter.cs
Normal file
29
BookAStar/BookAStar/Converters/BooleanToObjectConverter.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace BookAStar.Converters
|
||||||
|
{
|
||||||
|
class BooleanToObjectConverter<T> : IValueConverter
|
||||||
|
{
|
||||||
|
public T FalseObject { set; get; }
|
||||||
|
|
||||||
|
public T TrueObject { set; get; }
|
||||||
|
|
||||||
|
public object Convert(object value, Type targetType,
|
||||||
|
object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return (bool)value ? this.TrueObject : this.FalseObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType,
|
||||||
|
object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return ((T)value).Equals(this.TrueObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue