i have to write some circles to a canvas in wpf. i have this tutorial as a base but it won't work somehow: http://www.wpf-tutorial.com/list-controls/itemscontrol/
my xaml
<ItemsControl Name="icCircles">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Background="Transparent" Width="300" Height="500"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Canvas.Top="{Binding X}" Canvas.Left="{Binding Y}" Fill="Black" Height="5" Width="5" Stroke="Black" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
the code behind:
List<Circle> circles = new List<Circle>();
circles.Add(new Circle() { X = 50, Y = 50 });
circles.Add(new Circle() { X = 100, Y = 50 });
icCircles.ItemsSource = circles;
the circle class:
public class Circle
{
public int X { get; set; }
public int Y { get; set; }
}
if i add nothing to the list, i don't get anything. if i add one circle, i see it, but at X0/Y0. if i add a second one, i still see only one circle. possibly because they are at the same location.
what am i doing wrong?