WPF背景渐变、圆角、阴影

来源:互联网 时间:1970-01-01

只要支持相应属性,wpf的背景渐变、圆角、阴影是通用的,要注意的是,圆角其实就是用Border包住控件,设置Border的圆角就可以了。

<!--CornerRadius="3"是圆角的角度;BorderBrush="Black" BorderThickness="1"是线的颜色和线条宽度--><Border CornerRadius="3" BorderBrush="Black" BorderThickness="1" Width="338" Height="150" Margin="3"> <!--背景渐变--> <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> <GradientStop Color="Yellow" Offset="0.0"/> <GradientStop Color="White" Offset="0.93"/> </LinearGradientBrush> </Border.Background> <!--阴影--> <Border.Effect> <DropShadowEffect Opacity="0.6" Color="Black" ShadowDepth="3"/> </Border.Effect> <StackPanel> <WrapPanel> <TextBlock Text="{Binding [email protected],StringFormat='标题:{0}'}" Margin="3"/> </WrapPanel> <WrapPanel> <TextBlock Text="{Binding XPath=分类,StringFormat='分类:{0}'}" Margin="3"/> </WrapPanel> <WrapPanel> <TextBlock Text="{Binding XPath=创建时间,StringFormat='创建时间:{0}'}" Margin="3"/> </WrapPanel> </StackPanel></Border>

原文地址:http://www.luacloud.com/2011/06/07/wpf%e8%83%8c%e6%99%af%e6%b8%90%e5%8f%98%e3%80%81%e5%9c%86%e8%a7%92%e3%80%81%e9%98%b4%e5%bd%b1/

相关阅读:
Top