Example #1
0
        private void DisplaySuoSuo(SuoSuo ss)
        {
            if (ss == null || ss.msglist.Count == 0)
            {
                return;
            }

            var msg = ss.msglist.First();

            this.lbl_Date.Content  = msg.createTime.ToString("yyyy年MM月dd日");
            this.lbl_Time.Content  = ConvertUtil.ConvertFromJsTick(ConvertUtil.SafeConvertToLong(msg.created_time)).ToString("HH:mm:ss");
            this.tbox_Content.Text = msg.content;

            area_SuoSuoImage.Children.Clear();
            area_Comment.Children.Clear();
            area_Like.Children.Clear();

            if (msg.pic != null && msg.pic.Count > 0)
            {
                var columns = msg.pic.Count % 3;

                foreach (var item in msg.pic)
                {
                    Image image = new Image()
                    {
                        Width = (WindowWidth - 20) / columns, Height = Width, Margin = new Thickness(5), Stretch = Stretch.UniformToFill
                    };
                    BitmapImage bi = new BitmapImage();
                    bi.BeginInit();
                    bi.UriSource = new Uri(item.url3);
                    bi.EndInit();
                    image.Source = bi;

                    //设置缩略图Tooltip
                    System.Windows.Data.Binding binding = new System.Windows.Data.Binding();
                    //binding.ElementName = "image";
                    binding.Source = image;
                    binding.Path   = new PropertyPath("Source");
                    Image toolTipImage = new Image();
                    System.Windows.Controls.ToolTip toolTip = new System.Windows.Controls.ToolTip();
                    toolTipImage.SetBinding(Image.SourceProperty, binding);
                    toolTip.Content = toolTipImage;

                    image.ToolTip = toolTip;

                    area_SuoSuoImage.Children.Add(image);
                }
            }
        }