Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm pretty sure I'm missing the problem of your question, but the following code works for me:</p> <pre><code>&lt;Window.Resources&gt; &lt;Image x:Key="test" Source="/Images/ChangeCase.png"/&gt; &lt;/Window.Resources&gt; &lt;!-- Using a Resource for the Content --&gt; &lt;Button Width="100" Height="20" Content="{StaticResource test}"/&gt; &lt;!-- Specifying the Content directly --&gt; &lt;Button Width="100" Height="20"&gt; &lt;Image Source="/Images/ChangeCase.png"/&gt; &lt;/Button&gt; </code></pre> <p>Plus I spotted an error in your code:</p> <pre><code>&lt;Button Content="{{StaticResource closeImage}" [...] </code></pre> <p>should be:</p> <pre><code>&lt;Button Content="{StaticResource closeImage}" [...] </code></pre> <p><strong>I don't quite understand what your style is doing. Why do you have the Content Property set to a StaticResource when you want to specify the image via style?</strong> </p> <h2>Edit:</h2> <p>Alright, I tried your style and it also works for me.</p> <pre><code> &lt;Style x:Key="WindowToolboxButton" TargetType="{x:Type Button}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Button}"&gt; &lt;Grid x:Name="grid" Height="15" Width="15"&gt; &lt;Border x:Name="border" CornerRadius="2,2,2,2" BorderBrush="#FFBBCDD2" BorderThickness="1" Opacity="0" Margin="0"&gt; &lt;Border.Background&gt; &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt; &lt;GradientStop Color="#FF82A3AC" Offset="1"/&gt; &lt;GradientStop Color="#7FCDD9DC"/&gt; &lt;/LinearGradientBrush&gt; &lt;/Border.Background&gt; &lt;/Border&gt; &lt;Image x:Name="image" Source="/Images/ChangeCase.png" Stretch="None" VerticalAlignment="Center" HorizontalAlignment="Center" /&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;Button Width="100" Height="20" Content="Test" Style="{DynamicResource WindowToolboxButton}"/&gt; </code></pre> <p>The image is shown. However, I can't see your border due to the opacity-prop being set to 0. </p> <p>The content that is given directly on the button is overriden by the style.</p> <p>Maybe there is sth wrong with your image? Did you set its build-property to <strong>Resource</strong>?</p>
 

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