This is default behaviour. Styling disabled items is not something that is supported out of the box unless the control has an actual property for it. but you can easily implement something like this in a few different ways. One would be to create a custom Entry
with a bindable property called something like DisabledStyle
. You can then set a custom style for disabled Entry
fields.
Option 1: Custom Entry
public class ExtendedEntry : Entry
{
private Style normalStyle;
public Style DisabledStyle
{
get { return (Style)GetValue(DisabledStyleProperty); }
set { SetValue(DisabledStyleProperty, value); }
}
public static readonly BindableProperty DisabledStyleProperty = BindableProperty.Create(nameof(DisabledStyle), typeof(Style), typeof(ExtendedEntry), null, BindingMode.TwoWay, null, (obj, oldValue, newValue) => { });
public ExtendedEntry()
{
normalStyle = this.Style;
this.PropertyChanged += ExtendedEntry_PropertyChanged;
}
private void ExtendedEntry_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(IsEnabled) && this.DisabledStyle != null)
{
if (this.IsEnabled)
this.Style = normalStyle;
else
this.Style = DisabledStyle;
}
}
}
Option 2: Triggers
Another option would be to use a trigger:
<Entry Placeholder="enter name">
<Entry.Triggers>
<Trigger TargetType="Entry"
Property="IsEnabled" Value="True">
<Setter Property="BackgroundColor" Value="Yellow" />
</Trigger>
</Entry.Triggers>
</Entry>