方案1:
<Window.Resources> <ControlTemplate x:Key="CornerButton" TargetType="{x:Type Button}"> <Border BorderBrush="Green" BorderThickness="1" CornerRadius="10" Background="Red"> <ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> </ControlTemplate> <ControlTemplate x:Key="yuanjiaoBtn" TargetType="{x:Type Button}"> <Border BorderBrush="Gray" BorderThickness="0.5" CornerRadius="12" Background="Black"> <ContentPresenter Content="{TemplateBinding ContentControl.Content}"/> </Border> </ControlTemplate> <ControlTemplate x:Key="CornerTextBox" TargetType="{x:Type TextBox}"> <Border BorderBrush="Blue" BorderThickness="1" CornerRadius="10" Background="#FFD5F0D4"> <ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/> </Border> </ControlTemplate> </Window.Resources> <Canvas Background="#1b1b1b"> <Button x:Name="btnOK" Content="OK" Template="{StaticResource CornerButton}" Height="26" Canvas.Top="175" Width="61" Canvas.Left="58" Click="btnOK_Click"></Button> <Button x:Name="btnCancel" Content="Cancel" Template="{StaticResource yuanjiaoBtn}" Height="26" Canvas.Top="175" Width="61" Canvas.Left="138"></Button> <TextBox Template="{StaticResource CornerTextBox}" Canvas.Left="74" Canvas.Top="50" Height="23" Name="textBox1" Width="120" Background="#FF7FBC7D" /> <TextBox Template="{StaticResource CornerTextBox}" Canvas.Left="74" Canvas.Top="108" Height="23" Name="textBox2" Width="120" /> </Canvas>
方案2:
<Button Content="地图" Height="50" Margin="555,282,466,393" Width="50"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="0" CornerRadius="3,13,3,13" Name="PART_Background"> <Border.Background> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="White" Offset="0.0" /> <GradientStop Color="Silver" Offset="0.5" /> <GradientStop Color="White" Offset="0.0" /> </LinearGradientBrush> </Border.Background> <ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> <ControlTemplate.Triggers> <Trigger Property="UIElement.IsMouseOver" Value="True"> <Setter Property="Border.Background" TargetName="PART_Background"> <Setter.Value> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="Silver" Offset="0.0" /> <GradientStop Color="White" Offset="0.5" /> <GradientStop Color="Silver" Offset="0.0" /> </LinearGradientBrush> </Setter.Value> </Setter> </Trigger> <Trigger Property="ButtonBase.IsPressed" Value="True"> <Setter Property="UIElement.Effect"> <Setter.Value> <DropShadowEffect BlurRadius="10" Color="Black" Direction="0" Opacity="0.6" RenderingBias="Performance" ShadowDepth="0" /> </Setter.Value> </Setter> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button>