我正在使用 WPF 创建一个简单的按钮,我正在添加一个简单的按钮,我希望它始终具有与按钮相同的大小,每边减去一个像素。
问题是我不知道如何使用按钮的宽度属性来使用它。
任何人都可以帮忙吗?
谢谢。
<UserControl
Name="UC_Button_Close"
x:Class="Colman_UC.UC_Button_Close"
xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d= "http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc= "http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" RenderTransformOrigin="0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Grid MinWidth="70" MinHeight=" 30" Height=" 30" Width=" 70">
<Rectangle x:Name="MainRectangle" Stroke="Black" StrokeThickness="1" >
<Rectangle.BitmapEffect >
<DropShadowBitmapEffect Opacity="0.2" ShadowDepth="0" />
</Rectangle.BitmapEffect>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFAECAD2" Offset="1" />
<GradientStop Color="#FFB9D5DD" Offset="0" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<!-- Here is the line concerned -->
<Line x:Name="RectangleLight" Stroke="white" X1="1" Y1="1" X2="69" Y2="1"/>
<TextBlock x:Name="MainText" HorizontalAlignment="Center"
VerticalAlignment="Center" Margin="0,0,0,0" Text="Button"
FontFamily="Avenir" />
</Grid>