I need to add a IsVisible property to entry cell using custom property
(I used height to change as visibility change but the code is broken) like:
public class BindableEntryCell : EntryCell
{
public static readonly BindableProperty IsVisibleProperty =
BindableProperty.Create(
propertyName: "IsVisible",
returnType: typeof(bool),
declaringType: typeof(BindableEntryCell),
propertyChanged: OnIsVisibleChanged);
public bool IsVisible
{
get { return (bool)GetValue(IsVisibleProperty); }
set { SetValue(IsVisibleProperty, value); }
}
private static void OnIsVisibleChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is BindableEntryCell EntryCell)
{
EntryCell.IsVisible = (bool)newValue;
var YesHeight = EntryCell.Height;
var NoHeight = 0;
if ((bool)newValue)
EntryCell.Height = YesHeight;
else
EntryCell.Height = NoHeight;
}
}
}
Or Using Value Converter (but there is a binding error mismatch binding even i bend to double) like:
public class HeightToVisabilityConverter : BaseConverter<HeightToVisabilityConverter>
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var Cell = (EntryCell)parameter;
var height = Cell.Height;
if ((bool)value )
return 0;
else
return height;
}
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
or any other way, I thought using height but any thing is accepted, please help?