【发布时间】:2020-09-08 02:11:12
【问题描述】:
这似乎也是 Entry 中的行为。但我们可以在 Entry using Effects (https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/effects/) 中更改此行为。我们已经尝试过 CustomView 但整个行为都发生了变化 在 Xamarin.Forms 中,UWP 不会更新焦点状态下的背景颜色。在此,我创建了继承自 UWP 中的 TextBox 的“NumericTextBox”。我创建了一个“NumericTextBox_Forms”,继承自 XForms 中的 View。在 UWP Renderer 类中为“NumericTextBox”创建一个新实例并设置本机控件。请在下面找到我的示例。
<StackLayout Padding="0,20,0,0">
<Entry Keyboard="Numeric">
<Entry.Effects>
<local:FocusEffect/>
</Entry.Effects>
<Entry.Triggers>
<Trigger TargetType="Entry" Property="IsFocused" Value="True">
<Setter Property="BackgroundColor" Value="Yellow" />
</Trigger>
</Entry.Triggers>
</Entry>
<NumericTextBox_Forms>
<NumericTextBox_Forms.Effects>
<local:FocusEffect/>
</NumericTextBox_Forms.Effects>
<NumericTextBox_Forms.Triggers>
<Trigger TargetType="sync:SfMaskedEdit" Property="IsFocused" Value="True">
<Setter Property="BackgroundColor" Value="Blue" />
</Trigger>
</NumericTextBox_Forms.Triggers>
</NumericTextBox_Forms >
</StackLayout>
【问题讨论】:
标签: c# xamarin xamarin.forms uwp xamarin.uwp