Created
May 8, 2018 13:04
-
-
Save rdelrosario/6639bc0a7b0ac2795bf49d75b7136871 to your computer and use it in GitHub Desktop.
ExtendedEditorControl Forms Controls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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