文章参考网友分享的文章,但原文章链接一时找不到了。后期找到补上。
效果
代码
<Window x:Class="WpfApp1.MainWindow"
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"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBox FontSize="55"
FontWeight="Bold"
Text="Hello Word~"
Name="XAML_TXT"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Bottom" />
<Rectangle RenderTransformOrigin="0 0.5"
Margin="0,246,254,0"
Grid.RowSpan="2">
<Rectangle.Fill>
<VisualBrush Visual="{Binding ElementName=XAML_TXT}"></VisualBrush>
</Rectangle.Fill>
<Rectangle.RenderTransform>
<ScaleTransform ScaleY="-1"
ScaleX="1.5"></ScaleTransform>
</Rectangle.RenderTransform>
<Rectangle.OpacityMask>
<LinearGradientBrush StartPoint="0,0.7"
EndPoint="0,1">
<GradientStop Offset="0.2"
Color="Transparent"></GradientStop>
<GradientStop Offset="1.0"
Color="#44000000"></GradientStop>
</LinearGradientBrush>
</Rectangle.OpacityMask>
</Rectangle>
<Button Width="200"
Visibility="Collapsed"
Background="SkyBlue"
FontSize="30"
FontWeight="Bold">
<Button.OpacityMask>
<LinearGradientBrush StartPoint="0,0"
EndPoint="1,0">
<GradientStop Offset="0"
Color="AliceBlue" />
<GradientStop Offset="1"
Color="Transparent" />
</LinearGradientBrush>
</Button.OpacityMask>
</Button>
</Grid>
</Window>