[英]Add rounded corners to grid
I am trying to add a gradient background and rounded corners to a grid. 我正在尝试将渐变背景和圆角添加到网格中。 I have the gradient but I can't get the rounded corners to work. 我有渐变但我不能让圆角工作。 This is going to be a status display popup so that is the idea behind it. 这将是一个状态显示弹出窗口,因此它背后的想法。 Also is there a better way to set the gradient? 还有更好的方法来设置渐变吗?
<UserControl x:Class="TestWPFStatusDisplay.StatusDisplayDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
mc:Ignorable="d"
d:DesignHeight="154" d:DesignWidth="391">
<Grid>
<Border Name="mask" Background="White" CornerRadius="7"/>
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=mask}"/>
</Grid.OpacityMask>
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#ECF5FF" Offset="0"/>
<GradientStop Color="#9CB0CA" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label HorizontalAlignment="Center" Grid.Row="0" Content="Words"/>
<Image Grid.Row="1" gif:ImageBehavior.AnimatedSource= "Images/GeoCartaLoading.gif" Width="125" Height="50" Margin="25,3,0,0"/>
<Label Grid.Row="2" Content="Words"/>
<ProgressBar Grid.Row="3" Name="pb" Maximum="60" />
</Grid>
<Border CornerRadius="25" BorderBrush="Black" BorderThickness="1">
<Grid>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="content"/>
</Grid>
</Border>
This will create a border around your grid with a corner radius (and with a gradient brush): 这将在您的网格周围创建一个边角半径(并使用渐变画笔):
<Border CornerRadius="3">
<Border.Background>
<LinearGradientBrush>
<!-- Your gradient stops would go here -->
</LinearGradientBrush>
</Border.Background>
<Grid>
<!-- Your grid goes here -->
</Grid>
<Border>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.