WPF: Disappearing icons

∥☆過路亽.° 提交于 2019-12-03 07:12:43
Kent Boogaart

That's because your resource is an Image, which is a Control. Controls can only have one parent so it's effectively being re-parented in each MenuItem on the fly.

Your options are:

  1. Don't use Image and instead use ImageSource or even a string containing the URI of the image.
  2. Set the resource to non-shared with the x:Shared XAML attribute. This will create multiple Image controls as needed.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!