【发布时间】:2018-05-11 22:52:06
【问题描述】:
我有一个Entry,如果条目为空,我想在按下按钮时在其周围添加一个红色边框。因此我需要能够动态地改变颜色。 (标准验证器)
xaml:
<local:BorderChange Placeholder="Example Entry" BorderColor="#ff4444"></local:BorderChange>
PCL 控制:
namespace Project
{
public class BorderChange : Entry
{
public string BorderColor
{
get;
set;
}
}
}
iOS 自定义渲染器:
[assembly: ExportRenderer(typeof(BorderChange), typeof(BorderColorChange))]
namespace Project.iOS
{
public class BorderColorChange : EntryRenderer
{
//init color
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if(Control != null)
{
Control.Layer.BorderColor = UIColor.Blue; //This is where i want to add my color
}
}
}
}
- 如何将我的属性传递给 CustomRenderer,以便动态更改
BorderColor参数?
【问题讨论】:
标签: xamarin xamarin.forms xamarin.ios