Styled Lines in XAML Revisited
February 23, 2006
NYC
A couple weeks ago I discussed Styled Lines in XAML, and I couldn't get the correct statement to assign a StrokeDashArray attribute of an Ellipse element from the Dashes property of the static DashStyles.Dot property. I now have the solution:
-
StrokeDashArray="{Binding Source={x:Static DashStyles.Dot}, Path=Dashes}"
I don't know if this solution works under the January CTP, but it works under the February CTP, and that's all that's important because the January CTP is history. You can download or run the revised TwoEllipses2.xaml XAML file, or just look at it here:
-
<!-- ===============================================
TwoEllipses2.xaml (c) 2006 by Charles Petzold
=============================================== -->
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Ellipse Grid.Column="0"
Margin="0.5in"
Fill="Blue"
Stroke="Red"
StrokeThickness="36pt"
StrokeDashArray="{Binding Source={x:Static DashStyles.Dot}, Path=Dashes}"
StrokeDashCap="Round">
</Ellipse>
<Image Grid.Column="1"
Margin="0.5in">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<GeometryDrawing Brush="Blue">
<GeometryDrawing.Geometry>
<EllipseGeometry RadiusX="1"
RadiusY="1"
Center="0.5,0.5" />
</GeometryDrawing.Geometry>
<GeometryDrawing.Pen>
<Pen Thickness=".25"
Brush="Red"
DashCap="Flat"
DashStyle="{x:Static DashStyles.Dash}">
</Pen>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</Grid>