![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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 | Retrieving elements from a Grid in C#? Let's say I have a grid defined in XAML with 2 rows and 2 columns, with a button in each cell defined by the grid: <Grid x:Name="myGrid" > <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Button Grid.Row="0" Grid.Column="0" /> <Button Grid.Row="0" Grid.Column="1" /> <Button Grid.Row="1" Grid.Column="0" /> <Button Grid.Row="1" Grid.Column="1" /> </Grid> My question is, can I programmatically get a reference to a particular button object, given the row and column coordinates? For example, I'd love to be able to do this: Button buttonReference = myGrid.Children.get(0, 0); and have it return the button at 0,0 in the grid. While inspecting the API I can't seem to find something that would give me this desired functionality. System.Windows.Controls.Grid has a property Children (inherited from Panel) which returns a UIElementCollection. From there, the best you can do it get an Enumerator and loop through the children. There must be a way to pick out a single one, right? I'm going for performance as I will be updating the content of each grid child quite frequently, and I simply can't afford to enumerate the entire Children collection each time. Anyone found anything that may help? Regards, Jason |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adobe Photoshop Elements 6 & Adobe Premiere Elements 4 | Jorge131 | Vista music pictures video | 12 | 05-27-2008 08:54 PM |
| Can't delete elements in folder Recent elements | Gudmund Liebach Nielsen | Vista General | 1 | 05-05-2008 07:17 PM |
| Support for Adobe photoshop elements 5 or premier elements 3 on Vista 64 bits | Sébastien DELAYRE | Vista General | 5 | 03-26-2007 09:57 AM |
| WPF Grid? | john | Avalon | 0 | 11-19-2006 12:55 PM |
| Grid.Row Grid.Column set programatically at runtime | craig kelly-soens www.XpectWorld.com | Avalon | 0 | 01-10-2006 03:52 PM |