I have extendedentry and custom renderer classes
public class ExtendedEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.Click += (sender, evt) =>
{
var nativeEditText = (global::Android.Widget.EditText)Control;
nativeEditText.SetSelectAllOnFocus(true);
new Handler().PostDelayed(delegate
{
Control.InputType = 0;
try
{
InputMethodManager inputMethodManager = Control.Context.GetSystemService(Android.Content.Context.InputMethodService) as InputMethodManager;
if (inputMethodManager != null)
{
inputMethodManager.HideSoftInputFromWindow(Control.WindowToken, HideSoftInputFlags.None);
}
}
catch (Exception Ex)
{
}
}, 300L);
};
// Hide soft input keyboard
Control.FocusChange += (sender, evt) =>
{
// Select all on entry focus
var nativeEditText = (global::Android.Widget.EditText)Control;
nativeEditText.SetSelectAllOnFocus(true);
new Handler().PostDelayed(delegate
{
Control.InputType = 0;
try
{
InputMethodManager inputMethodManager = Control.Context.GetSystemService(Android.Content.Context.InputMethodService) as InputMethodManager;
if (inputMethodManager != null)
{
inputMethodManager.HideSoftInputFromWindow(Control.WindowToken, HideSoftInputFlags.None);
}
}
catch (Exception Ex)
{
}
}, 300L);
};
}
}
}
My custom entry:
public class ExtendedEntry : Entry
{
}
And my XAML file is like this:
<local:ExtendedEntry x:Name="BarcodeEntry" Text="{Binding Barcode}" Margin="0,0,0,0" HorizontalOptions="FillAndExpand" VerticalOptions="Start">
<Entry.Triggers>
<Trigger TargetType="Entry" Property="IsFocused" Value="True">
<Setter Property="BackgroundColor" Value="Yellow" />
<Setter Property="TextColor" Value="Black" />
</Trigger>
</Entry.Triggers>
</local:ExtendedEntry>
Trigger doesn't work.
But when I change to default entry control like this:
<Entry x:Name="BarcodeEntry" Text="{Binding Barcode}" Margin="0,0,0,0"HorizontalOptions="FillAndExpand" VerticalOptions="Start">
<Entry.Triggers>
<Trigger TargetType="Entry" Property="IsFocused" Value="True">
<Setter Property="BackgroundColor" Value="Yellow" />
<Setter Property="TextColor" Value="Black" />
</Trigger>
</Entry.Triggers>
</Entry>
The Trigger works.
What did i wrong?
Edit
The ExportRenderer row from Xamarin.Forms is in my renderer class.
[assembly: ExportRenderer(typeof(ExtendedEntry), typeof(ExtendedEntryRenderer))]