WPF setting a MenuItem.Icon in code

前端 未结 8 1069
心在旅途
心在旅途 2020-12-08 07:05

I have an images folder with a png in it. I would like to set a MenuItem\'s icon to that png. How do I write this in procedural code?

8条回答
  •  失恋的感觉
    2020-12-08 07:17

    For those of you using vb.net, to do this you need to use this: menuItem.Icon = New Image() With {.Source = New BitmapImage(New Uri("pack://application:,,,/your_assembly;component/yourpath/Image.png"))}

提交回复
热议问题