日期:2014-05-20 浏览次数:21088 次
已定义List<Canvas> li= new List<Canvas>(); private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { Canvas c1 = new Canvas(); Canvas c2 = new Canvas(); Canvas c3 = new Canvas(); Canvas c4 = new Canvas(); BitmapImage bi = new BitmapImage(); //图片 bi.BeginInit(); bi.UriSource = new Uri("UserPic/P_1.png", UriKind.Relative); bi.EndInit(); Image myImage1 = new Image(); myImage1.Stretch = Stretch.Fill; myImage1.Width = 20; myImage1.Height = 20; myImage1.Source = bi; c1.Children.Add(myImage1); TextBlock t_Id = new TextBlock(); t_Id.Text = "1023444"; c2.Children.Add(t_Id); TextBlock t_Jifen = new TextBlock(); t_Jifen.Text = "233"; c3.Children.Add(t_Jifen); TextBlock t_Money = new TextBlock(); t_Money.Text = "5000"; c4.Children.Add(t_Money); li.Add(c1); li.Add(c2); li.Add(c3); li.Add(c4); ListViewItem lvItem1 = new ListViewItem(); lvItem1.Content =li; listview.Items.Add(lvItem1); }