• silverlight combobox image label


    在combobox 同时显示图片,文字,如图:

    引用:using System.Windows.Media.Imaging;

    功能函数如下:

      /// <summary>
            /// combobox 下拉同時顯示 圖片文字
            /// </summary>
            /// <param name="_cmbImg"></param>
            /// <param name="ImgPath"></param>
            /// <param name="Title"></param>
            /// <returns></returns>
            public void  cmbImg( ComboBox _cmbImg,  string ImgPath, string Title)
            {
                BitmapImage bitmap = new BitmapImage();
                bitmap.UriSource = new Uri(ImgPath, UriKind.Relative);

                Image img = new Image()
                {
                    Width = 20,
                    Height = 15,
                    Margin = new Thickness(0),
                    Source = bitmap,
                    // Tag = "Images/ColorCard/" + str
                };

                Label lbl = new Label()
                {
                    Content =Title ,
                    FontFamily =  new FontFamily("Arial"),
                    FontSize =15

                };
        
                StackPanel stackPanels = new StackPanel();
                stackPanels.Orientation = Orientation.Horizontal;//水平 Orientation.Horizontal,垂直 Orientation.Vertical
                stackPanels.Children.Add(img);
                stackPanels.Children.Add(lbl);

                ComboBoxItem multipleCmb = new ComboBoxItem();
                multipleCmb.Content = stackPanels;

                _cmbImg.Items.Add(multipleCmb);

            }

    此功能函数有些不足之处:当在选择着 如 1516 粉红色,如何取得 1516这个值?请大家帮助想想,有什么办法可以解决?

  • 相关阅读:
    tushare包使用案例
    Matplotlib模块:绘图和可视化
    pandas使用
    django 表操作
    元数据Meta
    django关系类型字段
    django项目模型字段
    django项目mysite 2
    django安装使用xadmin
    GCC版本中没有GLIBCXX_3.4.15错误
  • 原文地址:https://www.cnblogs.com/aran/p/2118550.html
Copyright © 2020-2023  润新知