嘿大家我有自定义按钮渲染器,当您点击/按下时动画,但Xaml中的绑定不起作用。如果我将渲染器移除到按钮,Binding正在工作。这是我的代码。
[assembly: ExportRenderer(typeof(Xbutton), typeof(ButtonEventRenderer))]
namespace Sample.Droid.Renderer
{
public class ButtonEventRenderer: ButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
base.OnElementChanged(e);
Android.Widget.Button thiButton = Control;
thiButton.Touch += (sender, q) =>
{
if (q.Event.Action == MotionEventActions.Down)
{
thiButton.SetBackgroundColor(Android.Graphics.Color.Cyan);
}
else if (q.Event.Action == MotionEventActions.Up)
{
thiButton.SetBackgroundColor(Android.Graphics.Color.Blue);
}
};
}
}
}
当我删除按钮的渲染器时,ICommand Binding正在工作
<controls:Xbutton
Text="SIGN-UP"
Image="Add.png"
FontAttributes="Bold"
TextColor="White"
HorizontalOptions="FillAndExpand"
VerticalOptions="CenterAndExpand"
BackgroundColor="#40B5FF"
BorderRadius = "5"
BorderWidth = "2"
Command="{Binding MainPageCommnd}">
</controls:Xbutton>
如何解决这个问题?