Why will not this work:
<Button Width="200" Height="50">
<Button.Style>
<Style TargetType="Button">
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource Self}, Path=Height}"/>
<Setter Property="Background" Value="Blue"/>
<Style.Triggers>
<Trigger Property="Button.IsPressed" Value="true">
<Setter Property="Background" Value="green"/>
<Setter Property="Height" Value="20"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
<Button.Template>
<ControlTemplate>
<Canvas x:Name="MainCanvas" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
<Border
Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"
x:Name="Border"
CornerRadius="2"
BorderThickness="1"
Background="{TemplateBinding Background}"
BorderBrush="black">
<ContentPresenter
Margin="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
RecognizesAccessKey="True"/>
</Border>
</Canvas>
</ControlTemplate>
</Button.Template>
Hello
</Button>
Like this:
<Button Width="200" >
<Button.Style>
<Style TargetType="Button">
<Setter Property="Height" Value="50"/>
<Setter Property="Background" Value="Blue"/>
<Style.Triggers>
<Trigger Property="Button.IsPressed" Value="true">
<Setter Property="Background" Value="green"/>
<Setter Property="Height" Value="20"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
<Button.Template>
<ControlTemplate>
<Canvas x:Name="MainCanvas" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
<Border
Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"
x:Name="Border"
CornerRadius="2"
BorderThickness="1"
Background="{TemplateBinding Background}"
BorderBrush="black">
<ContentPresenter
Margin="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
RecognizesAccessKey="True"/>
</Border>
</Canvas>
</ControlTemplate>
</Button.Template>
Hello
</Button>
I want the button to shrink when I press it. This is a prototype for a custom control so the Style will be lift out to a Generics.xmal files later on. And why does it not show the 'Hello' string on the Button???