Visual Studio 对于 Mac 将不会创建按钮单击处理程序
Visual Studio for Mac will not create a button click handler
我看到了这个 但在我的例子中,当我输入 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, Property=Width, Factor=.3333, Constant=0}" />
<Button x:Name="btnEditElder" Text="Edit" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=.3333, Constant=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width,Factor=.3333,Constant=0}" />
<Button x:Name="btnDeleteElder" Text="Delete" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=.6666, Constant=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=.3333, Constant=0}" />
</RelativeLayout>
感谢您的建议。
问题的原因似乎是我命名 Button
元素的方式。都是小写字母开头的。
当我使用以大写字母开头的名称时,例如:
<RelativeLayout HorizontalOptions="FillAndExpand">
<Button
x:Name="AddPublisherButton"
Padding="10,10,10,10"
RelativeLayout.WidthConstraint="{ConstraintExpression Constant=0,
Factor=.3333,
Property=Width,
Type=RelativeToParent}"
RelativeLayout.XConstraint="{ConstraintExpression Constant=0,
Factor=.0000,
Property=Width,
Type=RelativeToParent}"
Text="Add"
Clicked="AddPublisherButton_Clicked"/>
<Button
x:Name="EditPublisherButton"
Padding="10,10,10,10"
RelativeLayout.WidthConstraint="{ConstraintExpression Constant=0,
Factor=.3333,
Property=Width,
Type=RelativeToParent}"
RelativeLayout.XConstraint="{ConstraintExpression Constant=0,
Factor=.3333,
Property=Width,
Type=RelativeToParent}"
Text="Edit"
Clicked="EditPublisherButton_Clicked"/>
<Button
x:Name="DeletePublisherButton"
Padding="10,10,10,10"
RelativeLayout.WidthConstraint="{ConstraintExpression Constant=0,
Factor=.3333,
Property=Width,
Type=RelativeToParent}"
RelativeLayout.XConstraint="{ConstraintExpression Constant=0,
Factor=.6666,
Property=Width,
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)
{
}
我看到了这个 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, Property=Width, Factor=.3333, Constant=0}" />
<Button x:Name="btnEditElder" Text="Edit" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=.3333, Constant=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width,Factor=.3333,Constant=0}" />
<Button x:Name="btnDeleteElder" Text="Delete" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=.6666, Constant=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=.3333, Constant=0}" />
</RelativeLayout>
感谢您的建议。
问题的原因似乎是我命名 Button
元素的方式。都是小写字母开头的。
当我使用以大写字母开头的名称时,例如:
<RelativeLayout HorizontalOptions="FillAndExpand">
<Button
x:Name="AddPublisherButton"
Padding="10,10,10,10"
RelativeLayout.WidthConstraint="{ConstraintExpression Constant=0,
Factor=.3333,
Property=Width,
Type=RelativeToParent}"
RelativeLayout.XConstraint="{ConstraintExpression Constant=0,
Factor=.0000,
Property=Width,
Type=RelativeToParent}"
Text="Add"
Clicked="AddPublisherButton_Clicked"/>
<Button
x:Name="EditPublisherButton"
Padding="10,10,10,10"
RelativeLayout.WidthConstraint="{ConstraintExpression Constant=0,
Factor=.3333,
Property=Width,
Type=RelativeToParent}"
RelativeLayout.XConstraint="{ConstraintExpression Constant=0,
Factor=.3333,
Property=Width,
Type=RelativeToParent}"
Text="Edit"
Clicked="EditPublisherButton_Clicked"/>
<Button
x:Name="DeletePublisherButton"
Padding="10,10,10,10"
RelativeLayout.WidthConstraint="{ConstraintExpression Constant=0,
Factor=.3333,
Property=Width,
Type=RelativeToParent}"
RelativeLayout.XConstraint="{ConstraintExpression Constant=0,
Factor=.6666,
Property=Width,
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)
{
}