I want to apply the same properies to all my Polygons:
Polygon polygon = new Polygon();
polygon.StrokeThickness = 2;
polygon.Stroke = Brushes.Black;
polygon.Fill = (Brush)FindResource("HatchBrush");
polygon.ToolTip = (Image)FindResource("GapImg");
How can i do this?
You can use the
Styleproperty.Define your style in a resource dictionary:
And then use FindResource for each
Polygon:If you need to apply the style to all your polygons just remove the
x:Keyand you will not even need to find the resource run-time.