如何解决Visual Studio for Mac 不会创建按钮单击处理程序
我已经看到了这个 question,但在我的例子中,当我输入 Clicked=""
并选择创建处理程序的选项时,我看到了这个:
它不会让我创建一个处理程序。 ?
代码片段:
<RelativeLayout HorizontalOptions="FillAndExpand">
<Button x:Name="btnAddElder" Text="Add" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativetoParent,Property=Width,Factor=.0000,Constant=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativetoParent,Factor=.3333,Constant=0}" />
<Button x:Name="btnEditElder" Text="Edit" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativetoParent,Constant=0}" />
<Button x:Name="btnDeleteElder" Text="Delete" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativetoParent,Factor=.6666,Constant=0}" />
</RelativeLayout>
感谢您的建议。
解决方法
问题的原因似乎是我命名 Button
元素的方式。它们都以小写字母开头。
当我使用以大写字母开头的名称时,例如:
<RelativeLayout HorizontalOptions="FillAndExpand">
<Button
x:Name="AddPublisherButton"
Padding="10,10,10"
RelativeLayout.WidthConstraint="{ConstraintExpression Constant=0,Factor=.3333,Property=Width,Type=RelativeToParent}"
RelativeLayout.XConstraint="{ConstraintExpression Constant=0,Factor=.0000,Type=RelativeToParent}"
Text="Add"
Clicked="AddPublisherButton_Clicked"/>
<Button
x:Name="EditPublisherButton"
Padding="10,Type=RelativeToParent}"
Text="Edit"
Clicked="EditPublisherButton_Clicked"/>
<Button
x:Name="DeletePublisherButton"
Padding="10,Factor=.6666,Type=RelativeToParent}"
Text="Delete"
Clicked="DeletePublisherButton_Clicked"/>
</RelativeLayout>
然后它确实创建了处理程序!见:
void AddElderButton_Clicked(System.Object sender,System.EventArgs e)
{
}
void EditElderButton_Clicked(System.Object sender,System.EventArgs e)
{
}
void DeleteElderButton_Clicked(System.Object sender,System.EventArgs e)
{
}
void AddPublisherButton_Clicked(System.Object sender,System.EventArgs e)
{
}
void EditPublisherButton_Clicked(System.Object sender,System.EventArgs e)
{
}
void DeletePublisherButton_Clicked(System.Object sender,System.EventArgs e)
{
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。