如何设置GeometryDrawing的绝对位置? 目前该线总是绘制在中央。 我想LineGeometery总是遵循图像控件上的对齐。如何设置WPF GeometryDrawing的绝对位置?
这里是我一起工作的一些(现在编辑)代码:
<Window x:Class="WpfProblem.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" >
<Grid Width="450" Height="160" Background="Beige" VerticalAlignment="Stretch">
<Border BorderBrush="Lime" BorderThickness="1" CornerRadius="80" Background="#1AFF0000" Margin="0">
<Image Width="420" Height="120" Stretch="None" >
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<LineGeometry StartPoint="0,30" EndPoint="299,30"/>
</GeometryDrawing.Geometry>
<GeometryDrawing.Pen>
<Pen Thickness="5" Brush="Black"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</Border>
</Grid>
</Window>
难道你不只是设置你已经在'`标签上定义的Canvas.Left和Canvas.Top属性? –
2010-12-21 20:55:37
Canvas.Top&Left没有帮助。问题是LineGeometery正在图像控件中对齐。 – jyoung 2010-12-21 22:07:34