I'm a newbie, using XAML with Xamarin Forms.
Here's the UI:
And here's the code:
<RelativeLayout x:Name="DeviceLayout" VerticalOptions="Center" HorizontalOptions="Center">
<RelativeLayout.WidthRequest>
...
</RelativeLayout.WidthRequest>
<RelativeLayout.HeightRequest>
....
</RelativeLayout.HeightRequest>
<RelativeLayout VerticalOptions="Fill" HorizontalOptions="Fill">
<Button x:Name="1" Clicked="OnClickCommand"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=Constant,
Constant=110}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=Constant,
Constant=5}"
BackgroundColor="Gray"
WidthRequest="30"
HeightRequest="30"
/>
<Button x:Name="2" Clicked="OnClickCommand"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=Constant,
Constant=185}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=Constant,
Constant=35}"
BackgroundColor="Purple"
WidthRequest="30"
HeightRequest="30"
/>
<Button x:Name="3" Clicked="OnClickCommand"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=Constant,
Constant=215}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=Constant,
Constant=115}"
BackgroundColor="Green"
WidthRequest="30"
HeightRequest="30"
/>
<Button x:Name="4" Clicked="OnClickCommand"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=Constant,
Constant=185}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=Constant,
Constant=185}"
BackgroundColor="Yellow"
WidthRequest="30"
HeightRequest="30"
/>
....
</RelativeLayout>
And here's my OnClickCommand method:
public void OnClickCommand (object sender, EventArgs e) {
var button = (Button)sender;
Console.WriteLine ("Clicked!");
}
The 'Clicked' event is not triggered only for the purple, green and yellow buttons (i.e. the buttons in the left hemisphere of the UI shown above).
Is this a bug or is there something wrong with my XAML layout?