我已经开始各种常见Image
此举为ResourceDictionary
,发现在我的WPF应用程序的异常行为。如果Image
用于MenuItem
和Button
的ToolBar
,当我打开Menu
时,图像在Button
上消失。从Window
形象XAML ResourceDictionary中工具栏上消失的时候菜单打开
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Image x:Key="NewImage"
Source="/SomeApplication;component/Resources/NewDocumentHS.png"
Stretch="None"/>
<!-- ... -->
相关XAML:
<Menu>
<MenuItem Header="_File">
<MenuItem Header="_New"
Command="{Binding NewCommand}"
Icon="{DynamicResource NewImage}" />
<!-- ... -->
<ToolBarTray>
<ToolBar>
<Button Command="{Binding NewCommand}"
Content="{DynamicResource NewImage}" />
我认为这是一种资源的ResourceDictionary
一个警告,但我无法发现此相应的修订。行为发生在StaticResource
和DynamicResource
之间。它也不会出现受影响,如果ResourceDictionary
站在自己的,或者如果它合并与他人。没有其他资源共享这个关键。
编辑:此外,加入PresentationOptions:Freeze="True"
的图像没有变化的情况。
这听起来与我在Silverlight 4中使用Path样式的经验非常类似!运行时只渲染应用资源的第一个实例,在那之后,形状(在我的情况下为矢量图标)应该是空的:(我还没有找到任何解决方法... – dain 2011-04-08 15:50:44