形状以斜线为背景 [英] Shape with slanted lines as background

查看:54
本文介绍了形状以斜线为背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以绘制

 < VisualBrushx:Key ="HatchBrush"TileMode ="Tile" Viewport ="0,0,10,10"ViewportUnits =绝对" Viewbox ="0,0,10,10"ViewboxUnits ="Absolute">< VisualBrush.Visual><画布>< Rectangle Fill ="Azure" Width ="10" Height ="10"/>< Path Stroke ="Purple" Data ="M 0 0 l 10 10"/></画布></VisualBrush.Visual></VisualBrush> 

只需更改参数等以适合您的应用程序

用法:

 <矩形宽度="80"高度="40"Fill ="{StaticResource HatchBrush}"/> 

Is possible to draw a Shape that has a background made by slanted lines?

An example with Rectangle (sorry for the image quality):

And if i want dashed lines or change the line properties (stroke, thickness..)?

解决方案

You can use solution from this article http://mark-dot-net.blogspot.com/2007/06/creating-hatched-patterned-brush-in-wpf.html

<VisualBrush
  x:Key="HatchBrush"
  TileMode="Tile" Viewport="0,0,10,10"
  ViewportUnits="Absolute" Viewbox="0,0,10,10"   
  ViewboxUnits="Absolute">
  <VisualBrush.Visual>
    <Canvas>
       <Rectangle Fill="Azure" Width="10" Height="10" />
       <Path Stroke="Purple" Data="M 0 0 l 10 10" />
    </Canvas>
  </VisualBrush.Visual>
</VisualBrush>

Just change the parameters etc. to fit your application

Usage:

<Rectangle Width="80" Height="40"
    Fill="{StaticResource HatchBrush}"/>

这篇关于形状以斜线为背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆