C#/Xamarin Maui
[Xamarin] 자동으로 크키 조절되는 Editor
kjun.kr
2019. 5. 28. 23:22
728x90
CustomExpandEditor Class 를 작성합니다.
public class CustomExpandEditor : Editor
{
public static BindableProperty IsExpandableProperty
= BindableProperty.Create(nameof(IsExpandable), typeof(bool), typeof(CustomExpandEditor), false);
{
public static BindableProperty IsExpandableProperty
= BindableProperty.Create(nameof(IsExpandable), typeof(bool), typeof(CustomExpandEditor), false);
public bool IsExpandable
{
get { return (bool)GetValue(IsExpandableProperty); }
set { SetValue(IsExpandableProperty, value); }
}
public CustomExpandEditor()
{
TextChanged += OnTextChanged;
}
private void OnTextChanged(object sender, TextChangedEventArgs e)
{
if (IsExpandable) InvalidateMeasure();
}
}
xaml 에 아래처럼 작성합니다.
<cntrols:CustomExpandEditor x:Name="memoEditor"
IsExpandable="true"
Placeholder = "내용"
PlaceholderColor="#95969B"
BackgroundColor="SkyBlue"
Margin="7,0,7,0"
MaxLength="50" />
IsExpandable="true"
Placeholder = "내용"
PlaceholderColor="#95969B"
BackgroundColor="SkyBlue"
Margin="7,0,7,0"
MaxLength="50" />
IsExpandable 이 true 인 경우에는 글자 수에 따라서 글자가 잘리지 않고 크기가 늘어납니다.
Android
iOS
728x90