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
'C# > Xamarin Maui' 카테고리의 다른 글
[Xamarin] NavigationPage 에서 ToolBar 제거 하기 (0) | 2020.03.03 |
---|---|
[Xamarin] OnBackButtonPressed 에서 DisplayAlert 사용방법 (0) | 2020.03.02 |
[Xamarin] ShellContent 동적 생성 및 DataTemplate 인자 보내기 (0) | 2020.02.04 |
[Xamarin] url image 가 표시 되지 않을 때 (0) | 2019.12.19 |
[Xamarin] Xamarin.AndroidX.Migration 설치 명령 (0) | 2019.12.03 |