首页 新闻 会员 周边

silverlight中listbox赋值问题

0
[已关闭问题]

下载解析xml 内有图片路径和给定的一个id

 XElement root = XElement.Parse(e.Result);
            var q = from mi in root.Elements("ImageNameItem")
                    select new
                    {
                        Left = double.Parse(mi.Attribute("Left").Value),
                        Top = double.Parse(mi.Attribute("Top").Value),
                        Angle = int.Parse(mi.Attribute("Angle").Value),
                        Image = mi.Attribute("Image").Value,
                        RollImage = mi.Attribute("RollImage").Value,
                        ID=int.Parse(mi.Attribute("ID").Value),
                        TrueUri=mi.Attribute("TrueUri").Value
                    };
            int duration = int.Parse(root.Attribute("Duration").Value) / 2;          
            foreach (var item in q)
            {   ImageNewsNameView//图片显示控件

                ImageNewsNameView innv = new ImageNewsNameView(duration, item.Image, item.RollImage);
                var img = innv;
                img.Angle = item.Angle;
                img.Opacity = 0.3;
                
                //赋值新uri id  只赋值了最后一次!!!。。。。
                innv.txtID.Items.Add(item.ID.ToString());
                innv.txtUri.Items.Add(item.TrueUri);

                innv.image.MouseLeftButtonDown += new MouseButtonEventHandler(image_MouseLeftButtonDown);
               
                myImageNewsNameView.Children.Add(img);
                Canvas.SetLeft(img, item.Left);
                Canvas.SetTop(img, item.Top);
            }

 

 void image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (clear)
            {
                if (int.Parse(innv.txtID.Items[0].ToString()) == 0)
                {ImageNewsView 点击图片显示较大图片空间
                    ImageNewsView inv = new ImageNewsView(innv.txtUri.Items[0].ToString());
                    this.myImageNewsView.Children.Add(inv);
                    clear = false;
                }

就是想问下。。foreach 循环为什么只赋值了最后一次??

越~、。的主页 越~、。 | 初学一级 | 园豆:0
提问于:2008-11-27 21:41
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册