Note that there are some explanatory texts on larger screens.

plurals
  1. PODisappearing icons in WPF
    primarykey
    data
    text
    <p>I'm looking to use some icons from the VS2008ImageLibrary/Actions/pngformat in my WPF application to get a more Visual Studio look and feel - like the "Insert Standard Items" command in WinForms.<br> I've added the images as resources, and referenced them in my xaml file:</p> <pre><code>&lt;DockPanel.Resources&gt; &lt;Image x:Key="NewIcon" Source="Toolbar Images/NewDocumentHS.png" Height="16" Width="16"/&gt; &lt;/DockPanel.Resources&gt; </code></pre> <p>And then I've added the image to the Menu and Toolbar</p> <pre><code>&lt;MenuItem Command="ApplicationCommands.New" Icon="{StaticResource NewIcon}"/&gt; &lt;!-- ... --&gt; &lt;Button Command="ApplicationCommands.Save"&gt;&lt;StaticResourceExtension ResourceKey="SaveIcon"/&gt;&lt;/Button&gt; </code></pre> <p>However, when I open the menu, the icon disappears from the Toolbar, as if the button was never there.I've read elsewhere that this kind of thing occurs due to .NET's lack of support for Vista Icons/Compressed PNGs, but I'm not sure this is exactly the same problem. My attempts to work around this by changing formats have failed, or given sub-optimal results (such as losing transparency). Does anyone know of a better way to do this?</p> <p>Edit: For other people having this issue, making duplicate entries with different keys in the &lt; DockPanel.Resources > tag for each reference seems to be a functional enough workaround, though I'd be concerned that the images might disappear again if they need to be reloaded for any reason.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload