![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| 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 | |||