I have a loop (about 30 iterations) in which I call a function that creates a new Polyline object:

  private Polyline MakeArrow() { Polyline pl = new Polyline(); pl.Style = Resources["ClosedTheme_Arrow"] as Style; return pl; } 

The problem is that the style is assigned only to the first element.
If you move the style from XAML directly into behind-code , then everything works as it should:

  private Polyline MakeArrow() { Polyline pl = new Polyline(); //pl.Style = Resources["ClosedTheme_Arrow"] as Style; Windows.UI.Xaml.Media.PointCollection pc = new Windows.UI.Xaml.Media.PointCollection(); pc.Add(new Windows.Foundation.Point(0, 0)); pc.Add(new Windows.Foundation.Point(4, 5)); pc.Add(new Windows.Foundation.Point(0, 10)); pl.Points = pc; pl.Stroke = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.White); return pl; } 

Of course, you can also leave the second option, you just want to understand why in the first case the program behaves so implicitly (from my point of view).


XAML style code:

 <Style x:Key="ClosedTheme_Arrow" TargetType="Polyline"> <Setter Property="Points" Value="0,0 4,5 0,10"/> <Setter Property="Stroke" Value="#fff"/> </Style> 

By the method of "scientific spear" it turned out that the problem is in this line of style:

 <Setter Property="Points" Value="0,0 5,4 10,0"/> 

It is she who is assigned only to the first element. Or dumps all the elements in one place and it seems that only one element is visible.

  • What does Resources["ClosedTheme_Arrow"] look like? - Mae
  • @NewDevelop There is a usual style object, I did not find anything suspicious there - user200141
  • I have a little crazy thought - maybe you need pl.Style = new Resources["ClosedTheme_Arrow"] ? - Mae
  • @NewDevelop Do not compile this way - user200141

0