private DependencyObject CriaMeuPin() { var MeuGrid = new Grid(); MeuGrid.RowDefinitions.Add(new RowDefinition()); MeuGrid.RowDefinitions.Add(new RowDefinition()); MeuGrid.Background = new SolidColorBrush(Colors.Transparent); var MeuRetangulo = new Rectangle { Fill = new SolidColorBrush(Colors.Red), Height = 10, Width = 22 }; MeuRetangulo.SetValue(Grid.RowProperty, 0); MeuRetangulo.SetValue(Grid.ColumnProperty, 0); MeuGrid.Children.Add(MeuRetangulo); var MeuPoligono = new Polygon() { Points = new PointCollection() { new Point(1, 0), new Point(22, 0), new Point(11, 40) }, Stroke = new SolidColorBrush(Colors.Red), Fill = new SolidColorBrush(Colors.Red) }; MeuPoligono.SetValue(Grid.RowProperty, 1); MeuPoligono.SetValue(Grid.ColumnProperty, 0); MeuGrid.Children.Add(MeuPoligono); return MeuGrid; }
private DependencyObject CreatePin() { //Creating a Grid element. var myGrid = new Grid(); myGrid.RowDefinitions.Add(new RowDefinition()); myGrid.RowDefinitions.Add(new RowDefinition()); myGrid.Background = new SolidColorBrush(Colors.Transparent); //Creating a Rectangle var myRectangle = new Rectangle {Fill = new SolidColorBrush(Colors.Black), Height = 20, Width = 20}; myRectangle.SetValue(Grid.RowProperty, 0); myRectangle.SetValue(Grid.ColumnProperty, 0); //Adding the Rectangle to the Grid myGrid.Children.Add(myRectangle); //Creating a Polygon var myPolygon = new Polygon() { Points = new PointCollection() {new Point(2, 0), new Point(22, 0), new Point(2, 40)}, Stroke = new SolidColorBrush(Colors.Black), Fill = new SolidColorBrush(Colors.Black) }; myPolygon.SetValue(Grid.RowProperty, 1); myPolygon.SetValue(Grid.ColumnProperty, 0); //Adding the Polygon to the Grid myGrid.Children.Add(myPolygon); return myGrid; }