在WPF ListView控件中添加几个列

时间:2016-12-20 12:49:46

标签: c# wpf

我有ListView

<ListView name="listView1" />

我想在代码后面添加Row几个字段:

1. string
2. Combobox
3. Checkbox

这就是我的尝试:

List<string> list = new List<string>();
tests.Add("Select country");
tests.Add("USA");
tests.Add("Germany");

ComboBox combobox = new ComboBox();
combobox.ItemsSource = options;

CheckBox checkbox = new CheckBox();

ListViewItem itm;
object[] abjects = new object[3];
abjects[0] = "my name" as string;
abjects[1] = combobox as ComboBox;
abjects[2] = checkbox as CheckBox;

itm = new ListViewItem();
itm.Content = abjects;
listView1.Items.Add(itm);

目前,结果是我在每个列中看到Object[] Array

1 个答案:

答案 0 :(得分:-1)

更新了代码,以便从代码隐藏(C#)创建WPF ListView列和数据显示。希望这可以帮到你:

public class FullActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_full);

    ImageView imageViewFull;

    imageViewFull = (ImageView) findViewById(R.id.imageViewFull);

    imageViewFull.setImageResource(R.mipmap.ic_launcher);

  }


}