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.
我正在尝试在 WPF(c#) 中创建一个自定义消息框。我需要将 MessageBoxImage 转换为 ImageSource。有什么办法吗?
您应该使用CreateBitmapSourceFromHIcon方法 ( msdn ) 和SystemIcons类 ( msdn )。
CreateBitmapSourceFromHIcon
SystemIcons
例子:
img.Source = Imaging.CreateBitmapSourceFromHIcon( SystemIcons.Warning.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());