WPF,SilverLight中直线的样式示例
来源:互联网 发布:网络授课平台 兼职 编辑:程序博客网 时间:2024/06/06 07:05
XAML代码:
// LineStyle.xaml
<Viewbox Width="600" Height="500"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas Width="600" Height="500">
<Canvas.Resources>
<DrawingBrush x:Key="MyGridBrushResource1" Viewport="0,0,100,100" ViewportUnits="Absolute" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<!--横线-->
<GeometryDrawing Geometry="M0,1 L10,1 M0,2 L10,2 M0,3 L10,3 M0,4 L10,4 M0,5 L10,5 M0,6 L10,6 M0,7 L10,7 M0,8 L10,8 M0,9 L10,9">
<GeometryDrawing.Pen>
<Pen Thickness="0.1" Brush="#CCCCFF" />
</GeometryDrawing.Pen>
</GeometryDrawing>
<!--竖线-->
<GeometryDrawing Geometry="M1,0 L1,10 M2,0 L2,10 M3,0 L3,10 M4,0 L4,10 M5,0 L5,10 M6,0 L6,10 M7,0 L7,10 M8,0 L8,10 M9,0 L9,10">
<GeometryDrawing.Pen>
<Pen Thickness="0.1" Brush="#CCCCFF" />
</GeometryDrawing.Pen>
</GeometryDrawing>
<!-- 这里是横线 -->
<GeometryDrawing Geometry="M0,0 L10,0">
<GeometryDrawing.Pen>
<Pen Thickness="0.1" Brush="DarkOrange" />
</GeometryDrawing.Pen>
</GeometryDrawing>
<!-- 这里是竖线 -->
<GeometryDrawing Geometry="M0,0 L0,10">
<GeometryDrawing.Pen>
<Pen Thickness="0.1" Brush="DarkOrange" />
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<!-- 这里是外框线 -->
<Style x:Key="MyGridBorderStyle">
<Setter Property="Border.Background" Value="{StaticResource MyGridBrushResource1}"/>
<Setter Property="Border.HorizontalAlignment" Value="Center"/>
<Setter Property="Border.VerticalAlignment" Value="Top"/>
<Setter Property="Border.BorderBrush" Value="Black"/>
<Setter Property="Border.BorderThickness" Value="1"/>
</Style>
</Canvas.Resources>
<Border Style="{StaticResource MyGridBorderStyle}">
<Canvas Width="630" Height="400">
<Line Stroke="Black" X1="0" Y1="20" X2="400" Y2="20" StrokeDashArray="1,1" StrokeThickness="30"/>
<Line Stroke="Black" X1="0" Y1="60" X2="400" Y2="60" StrokeDashArray="1,1,2" StrokeThickness="30" />
<Line Stroke="Black" X1="0" Y1="100" X2="400" Y2="100" StrokeDashArray="1,1,2,2"
StrokeThickness="30" StrokeDashCap="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Line Stroke="Black" X1="0" Y1="140" X2="400" Y2="140" StrokeDashArray="1,1,2,2" StrokeThickness="30"
StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Line Stroke="Black" X1="0" Y1="180" X2="400" Y2="180" StrokeDashArray="0,1"
StrokeThickness="30" StrokeDashCap="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Line Stroke="Black" X1="0" Y1="220" X2="400" Y2="220" StrokeDashArray="0,2" StrokeThickness="30"
StrokeDashCap="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Line Stroke="Black" X1="0" Y1="260" X2="400" Y2="260" StrokeDashArray="0,2,0,2" StrokeThickness="30"
StrokeDashCap="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Line Stroke="Black" X1="0" Y1="300" X2="400" Y2="300" StrokeDashArray="0,1,1" StrokeThickness="30"
StrokeDashCap="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Line Stroke="Black" X1="0" Y1="340" X2="400" Y2="340" StrokeDashArray="0,2,1,0" StrokeThickness="30"
StrokeDashCap="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
</Canvas>
</Border>
</Canvas>
</Viewbox>
运行效果:
- WPF,SilverLight中直线的样式示例
- WPF Silverlight Button样式
- Silverlight中样式的用法
- WPF中样式的设置
- Silverlight Chart(三) ----直线样式
- Silverlight与WPF中BeginInvoke的差异
- Silverlight/WPF中 动态Style 的问题
- Silverlight与WPF中BeginInvoke的差异
- Silverlight与WPF中BeginInvoke的差异
- WPF中RichTextBox设置文本的样式
- WPF中设置DataGrid的一些样式
- WPF 修改listbox中scollviewer的样式
- WPF 中Path路径的使用示例
- 【转】Silverlight与WPF中BeginInvoke的差异
- Silverlight样式的运用
- WPF的字体样式
- WPF 样式的应用
- wpf 样式的调用
- 关于清空Office剪切板的方法
- 压缩日志
- 在mingw下使用gtk(windows)
- 软件设计师考试大纲
- 利用uniread解决下的SQL*Plus命令行历史回调功能
- WPF,SilverLight中直线的样式示例
- 千里之行始于足下
- 理解和使用NT驱动程序的执行上下文(一)
- SqlServer整理收集
- 获取Divx的版本号(测试中)
- 链表和数组(转)
- 用户自定义的修复
- BPO概念的理解
- 连接浏览器SHELL窗口的代码