wpf border的边框渐变

weixin_38056302 2018-04-25 02:16:03


请问怎样把上图的两个渐变色组合起来,形成一个四个边框都是渐变色的border啊。
我知道可以让UI使用PS画一个,但是更希望使用WPF自有的东西解决他。
...全文
652 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38058113 2018-04-25
  • 打赏
  • 举报
回复
你好,
可以使用VisualBrush 来组合两个LinearGradientBrush, 下面的代码,你可以参考一下。
<Window x:Class="ColeWPFSample.BorderSample.Window1" 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:ColeWPFSample.BorderSample" mc:Ignorable="d" Title="Window1" Height="450" Width="800"> <Window.Resources> <ResourceDictionary> <LinearGradientBrush x:Key="UnderBrush" EndPoint="0,1"> <GradientStop Color="#FFFF0000" Offset="0" /> <GradientStop Color="#00FF0000" Offset="1" /> </LinearGradientBrush> <LinearGradientBrush x:Key="OverBrush" EndPoint="1,0"> <GradientStop Color="#00000000" Offset="0" /> <GradientStop Color="#FF000000" Offset="1" /> </LinearGradientBrush> <VisualBrush x:Key="CombinedBrush"> <VisualBrush.Visual> <Border Background="{StaticResource UnderBrush}"> <Rectangle Fill="{StaticResource OverBrush}" Width="1" Height="1" /> </Border> </VisualBrush.Visual> </VisualBrush> </ResourceDictionary> </Window.Resources> <Grid> <Border Name="Rect" Height="200" Width="200" Background="{StaticResource ResourceKey=CombinedBrush}" /> </Grid> </Window>

Best regards,
Zhanglong

473

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧