Skip to content

Instantly share code, notes, and snippets.

@tecnocrata
Created October 24, 2012 20:34
Show Gist options
  • Select an option

  • Save tecnocrata/3948699 to your computer and use it in GitHub Desktop.

Select an option

Save tecnocrata/3948699 to your computer and use it in GitHub Desktop.
Creating a cross on a grid
private void CreateSymbolX(Grid board)
{
var geometry = new PathGeometry { Figures = new PathFigureCollection() };
var line1 = new PathFigure
{
Segments = new PathSegmentCollection { new LineSegment { Point = new Point(25, 25) } },
StartPoint = new Point(0, 0)
};
var line2 = new PathFigure
{
Segments = new PathSegmentCollection { new LineSegment { Point = new Point(25, 0) } },
StartPoint = new Point(0, 25)
};
geometry.Figures.Add(line1);
geometry.Figures.Add(line2);
Path X = new Path()
{
Stroke = new SolidColorBrush(Colors.Red),
StrokeThickness = 10,
UseLayoutRounding = false,
Data = geometry,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center
};
Grid.SetRow(X, 0);
Grid.SetColumn(X, 0);
board.Children.Add(X);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment