Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Biding collection to shape

Closed Thread
 
Thread Tools Display Modes
Old 05-04-2006   #1 (permalink)
haggai.shachar@gmail.com
Guest


 

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

Old 05-04-2006   #2 (permalink)
Douglas Stockwell
Guest


 

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



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


 

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>

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
collection sms 2003 pghboemike PowerShell 0 06-21-2007 04:49 AM
[Beginner's question] Drawing / Visual / Shape confusion... Lloyd Dupont Avalon 0 05-31-2007 12:34 AM
fill a shape with a hatch brush joris.spriet@gmail.com Avalon 1 05-04-2007 06:48 AM
It is year 3026, and the Earth is in a bad shape jim Vista General 1 02-24-2007 03:01 AM
Deriving from Shape CSkinner Avalon 2 01-31-2006 07:00 AM








Vistax64.com 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 2005-2008

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 47 48 49 50