![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 |
| | #2 (permalink) |
| 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 |
| | #3 (permalink) |
| 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> |
| |
| |
![]() |
| 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 |