Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在图像控件中显示一个图标,我该怎么做。
System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\Users\bgh32648\Desktop\Filename.extension"); Image Img = new Image();
我想将图标分配给 img
public static ImageSource ToImageSource(this Icon icon) { ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon( icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); return imageSource; }
进而image.Source = icon.ToImageSource();
image.Source = icon.ToImageSource();