失败案例
<Border CornerRadius="3" Width="100" Height="100"> <StackPanel Background="Red"></StackPanel> </Border>
换成下面就成功?为什么?
<Border CornerRadius="3" Background="Red" Width="100" Height="100"> <StackPanel ></StackPanel> </Border>
1设备Button圆角
<Button x:Name="but1" Content="软件介绍" HorizontalAlignment="Left" Margin="126,356,0,0" VerticalAlignment="Top" Width="128" Click="Button_Click" FontSize="20" Height="35" > <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="10"> <Border.Background>#FF8EB4D4</Border.Background> <ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> </ControlTemplate> </Button.Template> </Button>
2 设置TextBox圆角
<TextBox HorizontalAlignment="Left" Height="24" Margin="43,192,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="98"> <TextBox.Resources> <Style TargetType="{x:Type Border}"> <Setter Property="CornerRadius" Value="8"/> <Setter Property="BorderBrush" Value="#c1d0dc"/> </Style> </TextBox.Resources> </TextBox>
3PasswordBox设置圆角
<PasswordBox x:Name="t2" HorizontalAlignment="Left" Margin="183,150,0,0" VerticalAlignment="Top" Width="114" Height="26" BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" FontSize="18" Password="
"> <PasswordBox.Resources> <Style TargetType="PasswordBox"> <Setter Property="PasswordChar" Value="●"/> <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/> <Setter Property="HorizontalContentAlignment" Value="Left"/> <Setter Property="Padding" Value="1"/> <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="AllowDrop" Value="true"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="PasswordBox"> <Border CornerRadius="8" x:Name="Bd" Background="White" BorderBrush="#c1d0dc" BorderThickness="1" OpacityMask="{x:Null}"> <ScrollViewer SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ContentHost" Template="{DynamicResource ScrollViewerControlTemplate1}"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </PasswordBox.Resources> </PasswordBox>
标签:圆角,Button,3PasswordBox,关于,设置,FF8EB4D4,WPF From: https://www.cnblogs.com/stweily/p/17139079.html