zoukankan      html  css  js  c++  java
  • 如果利用代码添加带图标的treeviewItem?

    代码如下:

    TreeViewItem CreateTreeViewItem(MyClass cls)

            {

                StackPanel panel = new StackPanel();

                panel.Orientation = Orientation.Horizontal;

     

                BitmapImage bitmap = new BitmapImage();

                bitmap.BeginInit();

                bitmap.UriSource = new Uri(@"pack://application:,,/Angel.png");

                bitmap.EndInit();

     

                Image img = new Image();

                img.Width = img.Height = 20;

                img.Source = bitmap;

     

                TextBlock tb = new TextBlock();

                tb.Text = cls.Name;

     

                panel.Children.Add(img);

                panel.Children.Add(tb);

     

                TreeViewItem tvi = new TreeViewItem();

                tvi.Header = panel;

                tvi.Tag = cls;

                return tvi;

            }

     

  • 相关阅读:
    It is unuseful to regret
    越难熬的时候,越要靠自己
    2019/11/11
    QT Http
    QT 初步认识
    模板
    RTTI(Runtime Type Infomation)
    位域
    C++ 多字节string转UTF-8 string
    C++ 读写csv文件
  • 原文地址:https://www.cnblogs.com/dunnice/p/640151.html
Copyright © 2011-2022 走看看