我在XAML前台文件里,没有<MenuItem.Icon>这个节呢而我在后台给MenuItem.Icon这个属性给值,界面上直接显示system.drwaing.bitmap我晕死miConfig.Icon = global::WpfApp.Properties.Resources.Start;

解决方案 »

  1.   

    哦,我现在找到menuitem.icon这个节了,但是还是没有图标显示呢。。在后台又怎么给值呢。。
      

  2.   

          <MenuItem>
                                <MenuItem.Icon>
                                    <StackPanel>
                                        <Image Source="/Console;component/Icon/Mini-brightgreen.png"></Image>
                                    </StackPanel>
                                </MenuItem.Icon>
                            </MenuItem>
      

  3.   

    还有就是为什么我现在在前台给了image的source,还是没显示出来呢?
      

  4.   

      try
                {
                    BitmapImage bi = new BitmapImage();
                    FileStream fs = new FileStream("c:\\imgDemo.bmp", FileMode.Create);
                    fs.Write(bHeadImage, 0, bHeadImage.GetLength(0));
                    fs.Close();
                    bi.BeginInit();
                    bi.StreamSource = new MemoryStream(bHeadImage, bHeadImage.GetLowerBound(0), bHeadImage.GetLength(0));
                    bi.EndInit();
                    this.imgHead.Source = bi;
                }
                catch { }
      

  5.   

    我晕,在wpf里面给menuitem添加个icon这么困难??我见menuitem提供了一个icon的属性,但是我这边用起有问题
      

  6.   

    你不是动态加载图片吗?
        public void HeadImageBind(byte[] bHeadImage)
            {
                try
                {
                    BitmapImage bi = new BitmapImage();
                    FileStream fs = new FileStream("c:\\imgDemo.bmp", FileMode.Create);
                    fs.Write(bHeadImage, 0, bHeadImage.GetLength(0));
                    fs.Close();
                    bi.BeginInit();
                    bi.StreamSource = new MemoryStream(bHeadImage, bHeadImage.GetLowerBound(0), bHeadImage.GetLength(0));
                    bi.EndInit();
                    this.imgUser.Source = bi;
                }
                catch { }
            }
    把你的图片转换成byte[] 调用上面的方法就行了
      

  7.   

    我仅仅只是想给Menuitem加个Icon而已。啊