Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created May 8, 2018 13:04
Show Gist options
  • Save rdelrosario/6639bc0a7b0ac2795bf49d75b7136871 to your computer and use it in GitHub Desktop.
Save rdelrosario/6639bc0a7b0ac2795bf49d75b7136871 to your computer and use it in GitHub Desktop.
ExtendedEditorControl Forms Controls
using System;
using Xamarin.Forms;
namespace ExtendedEditorSample.Controls
{
public class ExtendedEditorControl : Editor
{
public static BindableProperty PlaceholderProperty
= BindableProperty.Create(nameof(Placeholder), typeof(string), typeof(ExtendedEditorControl));
public static BindableProperty PlaceholderColorProperty
= BindableProperty.Create(nameof(PlaceholderColor), typeof(Color), typeof(ExtendedEditorControl), Color.LightGray);
public static BindableProperty HasRoundedCornerProperty
= BindableProperty.Create(nameof(HasRoundedCorner), typeof(bool), typeof(ExtendedEditorControl), false);
public static BindableProperty IsExpandableProperty
= BindableProperty.Create(nameof(IsExpandable), typeof(bool), typeof(ExtendedEditorControl), false);
public bool IsExpandable
{
get { return (bool)GetValue(IsExpandableProperty); }
set { SetValue(IsExpandableProperty, value); }
}
public bool HasRoundedCorner
{
get { return (bool)GetValue(HasRoundedCornerProperty); }
set { SetValue(HasRoundedCornerProperty, value); }
}
public string Placeholder
{
get { return (string)GetValue(PlaceholderProperty); }
set { SetValue(PlaceholderProperty, value); }
}
public Color PlaceholderColor
{
get { return (Color)GetValue(PlaceholderColorProperty); }
set { SetValue(PlaceholderColorProperty, value); }
}
public ExtendedEditorControl()
{
TextChanged += OnTextChanged;
}
~ExtendedEditorControl()
{
TextChanged -= OnTextChanged;
}
private void OnTextChanged(object sender, TextChangedEventArgs e)
{
if (IsExpandable) InvalidateMeasure();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment