728x90

Grid 에서 특정 Row 를 숨기는 방법


using System;
using System.Globalization;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Foobar.Converters
{

    public class StatusToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (Equals(value,null))
                return new GridLength(0);

            var status = value.ToString().ToLower();

            switch (status)
            {
                case ("active"):
                    {
                        return new GridLength(1, GridUnitType.Auto);
                    }
                default:
                    {
                        return new GridLength(0);
                    }
            }
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException("Only one way bindings are supported with this converter");
        }}
    }
}
<Grid AbsoluteLayout.LayoutFlags="All"
      AbsoluteLayout.LayoutBounds="0,1,1,1">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="{Binding Contact.Status, Converter={convert:StatusToVisibilityConverter}}" />
.....


728x90
Posted by kjun.kr
,