<inputLayout:SfTextInputLayout Hint="Name" LeadingViewPosition="Inside"
ContainerType="Outlined">
<Entry x:Name="entry" TextChanged="Entry_TextChanged"/>
<inputLayout:SfTextInputLayout.LeadingView>
<StackLayout Orientation="Horizontal" WidthRequest="120">
<Label Text="🗓" Margin="5,0,5,0" VerticalTextAlignment="Center"/>
<Label Text="Enter Name" x:Name="label1" VerticalTextAlignment="Center"/>
</StackLayout>
</inputLayout:SfTextInputLayout.LeadingView>
</inputLayout:SfTextInputLayout>
|
private void Entry_TextChanged(object sender, TextChangedEventArgs e)
{
if(Regex.IsMatch(entry.Text, @"^[a-zA-Z]+$"))
{
label1.Text = "Enter Name";
label1.TextColor = Color.Black;
}
else
{
label1.Text = "Invalid Name";
label1.TextColor = Color.Red;
}
} |
public class SfTextInputLayoutExt : SfTextInputLayout
{
public SfTextInputLayoutExt() :base()
{
Grid grid = typeof(SfTextInputLayout).GetField("bottomGrid", System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance).GetValue(this) as Grid;
Grid.SetColumn(grid, 0);
}
}
|
<local:SfTextInputLayoutExt Hint="Name" LeadingViewPosition="Inside"
HelperText="Enter Name" ShowHelperText="True"
ContainerType="Outlined">
<Entry x:Name="entry" />
<inputLayout:SfTextInputLayout.LeadingView>
<Label Text="🗓"/>
</inputLayout:SfTextInputLayout.LeadingView>
</local:SfTextInputLayoutExt>
|