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

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

Closed Thread
 
Thread Tools Display Modes
Old 06-20-2006   #1 (permalink)
Phillip M. Hoff
Guest


 

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>
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
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? J Vista file management 0 07-17-2008 10:22 PM
in a bind tony Vista mail 1 09-07-2007 09:07 PM
Bind to LDAP Directory Tom G. PowerShell 11 12-27-2006 12:59 PM
UserControl cannot bind to its own properties? lubomir@gmail.com Avalon 3 01-31-2006 06:59 AM
Grid.Row Grid.Column set programatically at runtime craig kelly-soens www.XpectWorld.com Avalon 0 01-10-2006 03:52 PM








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