Skip to content

Instantly share code, notes, and snippets.

@PrinceNebulon
Created January 27, 2012 22:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PrinceNebulon/1691173 to your computer and use it in GitHub Desktop.
Save PrinceNebulon/1691173 to your computer and use it in GitHub Desktop.
WPF "No Chrome Button" style
<!-- Style -->
<Style x:Key="NoChromeButton" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="Chrome" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#ADADAD"/>
<Setter Property="Opacity" TargetName="Chrome" Value="0.5"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Usage -->
<Button Style="{DynamicResource NoChromeButton}" Margin="0,45,4,0" Height="24" Name="btnName" Cursor="Hand" VerticalAlignment="Top" HorizontalAlignment="Right" Width="24" Click="btnName_Click">
<Image Source="/Resources/24/add.png" ToolTip="Add Requirement" />
</Button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment