Windows phone 8 Xamarin Windows条目背景色

Windows phone 8 Xamarin Windows条目背景色,windows-phone-8,xamarin,xamarin.ios,xamarin.android,xamarin.forms,Windows Phone 8,Xamarin,Xamarin.ios,Xamarin.android,Xamarin.forms,在我的Xamarin表单应用程序中,我需要在条目控件获得foucs时更改其背景色。我添加了自定义渲染器,但默认白色在Windows应用程序中具有焦点时不会改变。它在ios和android中运行良好。这是我为windows定制的渲染器 公共类MyCustomEntryRenderer:EntryRenderer { 受保护的覆盖无效OnElementChanged(ElementChangedEventArgs e) { if(控件!=null) { Control.Foreground=新的So

在我的Xamarin表单应用程序中,我需要在条目控件获得foucs时更改其背景色。我添加了自定义渲染器,但默认白色在Windows应用程序中具有焦点时不会改变。它在ios和android中运行良好。这是我为windows定制的渲染器

公共类MyCustomEntryRenderer:EntryRenderer { 受保护的覆盖无效OnElementChanged(ElementChangedEventArgs e) { if(控件!=null) { Control.Foreground=新的SolidColorBrush(Colors.Transparent); Control.Background=新的SolidColorBrush(Colors.Transparent); } 基础。一个要素发生变化(e); } 受保护的覆盖无效OnElementPropertyChanged(对象发送方, System.ComponentModel.PropertyChangedEventArgs(e) { if(控件!=null) { Control.Foreground=新的SolidColorBrush(Colors.Transparent); Control.Background=新的SolidColorBrush(Colors.Transparent); } base.OnElementPropertyChanged(发送方,e); } }
WindowsPhone
在这种情况下有点奇怪,因为它在某些情况下会重置背景色


要解决此问题,您还需要挂接平台特定控件本身的
GotFocus
LostFocus
事件。

WindowsPhone
在这一点上有点奇怪,因为它在某些场景中会重置背景颜色


要解决此问题,您还需要挂接平台特定控件本身的
GotFocus
LostFocus
事件。

您需要覆盖默认的文本框样式。 您可以在App.xaml中添加样式,如下所示: