C# 在C中添加单选按钮和分级视图#
在foor循环中,我需要根据obj值创建一个项: 例如:C# 在C中添加单选按钮和分级视图#,c#,xamarin.forms,radio-button,rate,C#,Xamarin.forms,Radio Button,Rate,在foor循环中,我需要根据obj值创建一个项: 例如: for(int i=0;i<mylist.count;i++) if(mylist[i].type==1) { //create radiobutton } else if(mylist[i].type==2) { //create ratingview } 用于(int i=0;i解决方案: 如果找不到标记属性,只需创建一个: public void test() { for (int i = 0; i < 10
for(int i=0;i<mylist.count;i++)
if(mylist[i].type==1)
{
//create radiobutton
}
else if(mylist[i].type==2)
{
//create ratingview
}
用于(int i=0;i解决方案:
如果找不到标记属性,只需创建一个:
public void test() {
for (int i = 0; i < 10; i++)
if (i<5)
{
//create radiobutton
radiobutton btn = new radiobutton
{
Text = "Click to Rotate Text!",
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.Center,
tag = i
};
Console.WriteLine(btn.tag);
}
else if (i > 2)
{
//create ratingview
}
}
public class radiobutton : Button
{
public int tag;
}
公共无效测试(){
对于(int i=0;i<10;i++)
如果(i)2
{
//创建分级视图
}
}
公共类单选按钮:按钮
{
公共int标签;
}