Hi there
My Clicked event handler is not triggering on a physical device, but works Ok on a simulator.
The code is as following:
1. First page has a Button. It triggers, thank goodness.
2. The event handler for that Clicked:
public void Login_Click(object sender, EventArgs args)
{
MainMenuPage mpage = new MainMenuPage();
Device.BeginInvokeOnMainThread(() => Navigation.PushModalAsync(mpage));
}
- MainMenuPage is the ContentPage. Its OnAppearing event handler is as following
protected override void OnAppearing()
{
base.OnAppearing();
Button btn = new Button();
btn.Text = "Click me";
btn.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
btn.Clicked += (s, e) =>
{
btn.AnchorX = 0; //<-- NEVER TRIGGERS ON A PHYSICAL DEVICE! WHY?
};
LayoutRoot.Children.Add(btn);
}
When I start it and switch to a MainMenuPage page, I can see it and a Button "Click me" on it. If I click that button, I can see it "blinks" like it reacts, but Clicked event fires only if I use a simulator. My iPad device never triggers it.
What a spooky behavior :-)
Why that is happening and how to fix it?
Thanks.