【发布时间】:2016-06-09 04:55:24
【问题描述】:
在我的 Xamarin 表单应用程序中,当 Entry 控件出现焦点时,我需要更改它的背景颜色。我添加了自定义渲染器,但是当它在 Windows 应用程序中具有焦点时,默认的白色不会改变。它在 ios 和 android 中运行良好。这是我的 windows 自定义渲染器。
public class MyCustomEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
if (Control != null)
{
Control.Foreground = new SolidColorBrush(Colors.Transparent);
Control.Background = new SolidColorBrush(Colors.Transparent);
}
base.OnElementChanged(e);
}
protected override void OnElementPropertyChanged(object sender,
System.ComponentModel.PropertyChangedEventArgs e)
{
if (Control != null)
{
Control.Foreground = new SolidColorBrush(Colors.Transparent);
Control.Background = new SolidColorBrush(Colors.Transparent);
}
base.OnElementPropertyChanged(sender, e);
}
}
【问题讨论】:
-
您使用的是哪个版本的 Xamarin.Forms?
标签: windows-phone-8 xamarin xamarin.ios xamarin.android xamarin.forms