WPF:在图像元素中使用特定的图标图像

标签 wpf wpf-controls icons

如何让 System.Windows.Controls.Image 使用 .ico 资源中具有指定分辨率和颜色深度的图像?

最佳答案

创建一个 BitmapFrame 并使用它的解码器。例如,要访问 48x48、32 位图像:

BitmapFrame icon = BitmapFrame.Create(new Uri("pack://application:,,,/Resources/Icon.ico", UriKind.Absolute));
BitmapFrame image = icon.Decoder.Frames.First(f => f.PixelHeight == 48 && f.Format.BitsPerPixel == 32);

关于WPF:在图像元素中使用特定的图标图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4196239/

相关文章:

c# - 将 Dialog/WebBrowser 调整为网页宽度

c# - 将 child 添加到 UserControl

c# - XAML 中的映射命名空间不起作用

android - Android 3.0 中选项卡的样式指南是什么?

java - 图标与具有海玻璃外观和感觉的 JButton 不匹配

c# - 从方法返回更新

c# - TabItem 绑定(bind) WPF

wpf - 为什么 VS.NET 尝试为 WPF 和 ClickOnce 包含 Microsoft.Windows.Design.Extensibility?

c# - 在 WPF 中,如何获取当前主题的按钮背景?

java - Android ListView 带有来自 URL 的自定义图标