Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, it's not a good practice to set first the background with a static resource and then use code to set it each time to a new ImageBrush object. Have a look at the FindResource method (<a href="http://msdn.microsoft.com/de-de/library/system.windows.frameworkelement.findresource(v=vs.110).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/de-de/library/system.windows.frameworkelement.findresource(v=vs.110).aspx</a>) to use your resources in code behind.</p> <p>Second, you should use Styles and Triggers to modify the appearance of a control depending for example on the MouseOver-State. There is a property called IsMouseOver which you can use for that. Here is an example:</p> <pre><code>&lt;Page.Resources&gt; &lt;Style TargetType="Button" x:Key="myButtonStyle"&gt; &lt;Setter Property="Foreground" Value="Red" /&gt; &lt;Setter Property="FontSize" Value="12" /&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="true"&gt; &lt;Setter Property="Foreground" Value="Blue" /&gt; &lt;Setter Property="Cursor" Value="Hand"/&gt; &lt;Setter Property="FontSize" Value="16" /&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/Page.Resources&gt; &lt;Button Width="200" Height="100" Style="{StaticResource myButtonStyle}"&gt;Hello, World!&lt;/Button&gt; </code></pre> <p>Third, because of the default template of a WPF button, you cannot change directly the background of it when hovering with the mouse. This problem is discussed and solved here: <a href="https://stackoverflow.com/questions/17259280/mouseover-button-background">How do you change Background for a Button MouseOver in WPF?</a> If you want to have more Information about styling WPF controls and how to use the default templates, have a look here: <a href="http://msdn.microsoft.com/en-us/library/aa970773.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa970773.aspx</a></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.
    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