2012-06-14 74 views
3

是否可以绘制具有由倾斜线形成的背景的Shape以倾斜线为背景的形状

Rectangle(遗憾的图像质量)的一个例子:

enter image description here

如果我想虚线或更改行属性(中风,厚度..)?

回答

2

您可以使用解决方案从本文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> 

只要改变参数等,以满足您的应用

用法:

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

@Nick比你必须使用方法FindResource(“HatchBrush”)的主窗口(如果您在主窗口中存储此资源)或应用程序中。只要看看方法_FindResource_ – Ribtoks

+0

谢谢,我现在得到它。 – Nick