Wpf Button syle
-
Monday, April 30, 2012 5:37 PMDee
Hi,
1) How to create button like this in wpf

Pleas help me
Thanks
- Edited by Dee Choksi Monday, April 30, 2012 5:40 PM
All Replies
-
Monday, April 30, 2012 5:57 PM
Following code should help you get started. You can change the CornerRadius property of Border in the below style to get result as per your requirement.
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <Style TargetType="{x:Type Button}" x:Key="MyButton"> <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="Foreground" Value="Black"/> <Setter Property="Background" Value="Orange"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Padding" Value="4"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0,15,15,0"> <ContentPresenter Name="Chrome" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/> </Border> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Opacity" Value="0.6"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid> <Button Height="28" Width="24" Style="{StaticResource MyButton}"/> </Grid> </Window>
Gaurav Khanna | Microsoft VB.NET MVP
- Marked As Answer by Dee Choksi Monday, April 30, 2012 8:50 PM

