Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You won't need dependency properties because you are inheriting from <code>Button</code>. You already have the <code>IsPressed</code> and <code>IsEnabled</code> properties. In fact, this is all you need:</p> <pre><code>&lt;Button x:Class="TestWpfApplication.ThreeStateImageButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;Button.Template&gt; &lt;ControlTemplate TargetType="{x:Type Button}"&gt; &lt;Grid&gt; &lt;Image Name="Normal" Source="Resources/Normal.png"/&gt; &lt;Image Name="Pressed" Source="Resources/Pressed.png" Visibility="Hidden"/&gt; &lt;Image Name="Disabled" Source="Resources/Disabled.png" Visibility="Hidden"/&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsPressed" Value="True"&gt; &lt;Setter TargetName="Normal" Property="Visibility" Value="Hidden"/&gt; &lt;Setter TargetName="Pressed" Property="Visibility" Value="Visible"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsEnabled" Value="False"&gt; &lt;Setter TargetName="Normal" Property="Visibility" Value="Hidden"/&gt; &lt;Setter TargetName="Disabled" Property="Visibility" Value="Visible"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Button.Template&gt; &lt;/Button&gt; </code></pre> <p>With your UserControl code-behind file:</p> <pre><code>public partial class ThreeStateImageButton : Button { public ThreeStateImageButton() { InitializeComponent(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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