Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Biding collection to shape

 
 
Old 05-04-2006   #1 (permalink)
haggai.shachar@gmail.com


 
 

Biding collection to shape

Hi,
I have an XML with points coordination and i'd like to draw a circle on
each of that points.
How do I bind that XML to a shape object with the minimum amount of
code possible?

I guess it has to do with ItemsControl but documentation / examples are
very poor.

Thanks,
Haggai


My System SpecsSystem Spec
Old 05-04-2006   #2 (permalink)
Douglas Stockwell


 
 

Re: Biding collection to shape

This probably won't compile, but it should get you started:

<ItemsControl ItemsSource="{Binding XPath=/select/points}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Width="25" Height="25" Fill="Pink" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Canvas.X" Value="{Binding XPath=X}" />
<Setter Property="Canvas.Y" Value="{Binding XPath=Y}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.Template>
<ControlTemplate>
<Canvas IsItemsHost="True" />
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>

- Doug

> Hi,
> I have an XML with points coordination and i'd like to draw a circle
> on
> each of that points.
> How do I bind that XML to a shape object with the minimum amount of
> code possible?
> I guess it has to do with ItemsControl but documentation / examples
> are very poor.
>
> Thanks,
> Haggai



My System SpecsSystem Spec
Old 05-04-2006   #3 (permalink)
haggai.shachar@gmail.com


 
 

Re: Biding collection to shape

Thank, it works..

just one tiny thingy
In Feb CTP - it's Canvas.Top & Canvas.Lef (instead of Canvas.X &
Canvas.Y)

here's a sample:

<StackPanel
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel.Resources>
<XmlDataProvider x:Key="itemData">
<x:XData>
<points xmlns="">
<point>
<x>10</x>
<y>10</y>
</point>
<point>
<x>30</x>
<y>30</y>
</point>
<point>
<x>50</x>
<y>50</y>
</point>
<point>
<x>70</x>
<y>70</y>
</point>
</points>
</x:XData>
</XmlDataProvider>
</StackPanel.Resources>
<ItemsControl ItemsSource="{Binding Source={StaticResource itemData},
XPath=//points/point}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Width="25" Height="25" Fill="Pink"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style >
<Setter Property="Canvas.Top" Value="{Binding XPath=x}" />
<Setter Property="Canvas.Left" Value="{Binding XPath=y}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.Template>
<ControlTemplate>
<Canvas IsItemsHost="True" />
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
</StackPanel>

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
'When Windows is executing well, Microsoft is in good shape.' Vista News
It is year 3026, and the Earth is in a bad shape Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46