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 - Bind to a particular row and column of a dynamic grid?

 
 
Old 06-20-2006   #1 (permalink)
Phillip M. Hoff


 
 

Bind to a particular row and column of a dynamic grid?

I'm new to WPF, so perhaps I'm going about this the wrong way. I'm
trying to create a grid that contains a collection of objects. The
number of rows and columns of this grid is dynamic; ideally those
properties would be bound to a couple of properties of a custom object.
The position of the objects within the grid would ideally be bound to
properties of those objects themselves.

A Grid allows items to be bound to particular rows/columns, but the
total number of rows/columns must be static (at least, from a pure XAML
perspective). The UniversalGrid allows binding to the total number of
rows/columns, but items cannot be bound to particular rows/columns (they
simply flow horizontally, wrapping with the number of columns).

Below is the closest I can get to what I want. Am I on the right track?
Can anyone point me in a new direction? I'm beginning to suspect it
may require some codebehind.

Thanks in advance,

-Phil


<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

<Page.Resources>

<XmlDataProvider x:Key="InventoryData" XPath="Inventory">

<x:XData>

<Inventory xmlns="">

<Wafer rows="3" columns="3">

<Die row="0" column="0" value="One"/>

<Die row="1" column="1" value="Two"/>

<Die row="2" column="2" value="Three"/>

</Wafer>

</Inventory>

</x:XData>

</XmlDataProvider>



</Page.Resources>

<ItemsControl>

<ItemsControl.ItemsSource>

<Binding Source="{StaticResource InventoryData}"
XPath="Wafer/Die"/>

</ItemsControl.ItemsSource>

<ItemsControl.ItemsPanel>

<ItemsPanelTemplate>

<UniformGrid IsItemsHost="True">

<UniformGrid.Rows>

<Binding Source="{StaticResource InventoryData}" XPath="Wafer/@rows"/>

</UniformGrid.Rows>

<UniformGrid.Columns>

<Binding Source="{StaticResource InventoryData}"
XPath="Wafer/@columns"/>

</UniformGrid.Columns>

</UniformGrid>

</ItemsPanelTemplate>

</ItemsControl.ItemsPanel>

<ItemsControl.ItemTemplate>

<DataTemplate>

<Button Grid.Row="{Binding XPath=@row}" Grid.Column="{Binding
XPath=@column}" Content="{Binding XPath=@value}"/>

</DataTemplate>

</ItemsControl.ItemTemplate>

</ItemsControl>

</Page>

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Is it possible in "computer" to view files from top to bottom in 1st column then same again in next column to the right etc? Vista file management
How to bind to AD without displaying the Distinguished Name PowerShell
in a bind Vista mail
Bind to LDAP Directory PowerShell


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