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 - Databinding a list of items into a panel

 
 
Old 04-24-2006   #1 (permalink)
jods


 
 

Databinding a list of items into a panel

I am databinding a list of items into an ItemsControl. I want each item to
have a specific position on the screen (which would be - ideally -
databound). So I changed the ItemsPanel to a Canvas.

It works perfectly if I don't use the databound version (i.e., if I simply
write items down inside the ItemsControl). But if I use the ItemsSource
property, the Canvas.Top property seems to be ignored (all items are
displayed at 0)!

The relevant code fragment is below:

<UserControl x:Class="Octgn.Play.Gui.TableControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gui="clr-namespace:MyNamespace.Gui">

<UserControl.Resources>
<DataTemplate x:Key="CardTemplate">
<gui:CardControl Canvas.Top="30" />
</DataTemplate>
</UserControl.Resources>

<ItemsControl x:Name="presenter" ItemsSource="{Binding Cards}"
ItemTemplate="{StaticResource CardTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>

</UserControl>

I've spent a huge amount of time trying to get this to work, without success
so far. So thank you very much if you can tell me what's wrong with it.

My System SpecsSystem Spec
Old 04-24-2006   #2 (permalink)
viliescu


 
 

RE: Databinding a list of items into a panel

See
http://www.i-constructions.com/myblo...tabinding.html

Hope this helps.
--
Valentin Iliescu [MVP - Client Application Development]


"jods" wrote:

> I am databinding a list of items into an ItemsControl. I want each item to
> have a specific position on the screen (which would be - ideally -
> databound). So I changed the ItemsPanel to a Canvas.
>
> It works perfectly if I don't use the databound version (i.e., if I simply
> write items down inside the ItemsControl). But if I use the ItemsSource
> property, the Canvas.Top property seems to be ignored (all items are
> displayed at 0)!
>
> The relevant code fragment is below:
>
> <UserControl x:Class="Octgn.Play.Gui.TableControl"
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> xmlns:gui="clr-namespace:MyNamespace.Gui">
>
> <UserControl.Resources>
> <DataTemplate x:Key="CardTemplate">
> <gui:CardControl Canvas.Top="30" />
> </DataTemplate>
> </UserControl.Resources>
>
> <ItemsControl x:Name="presenter" ItemsSource="{Binding Cards}"
> ItemTemplate="{StaticResource CardTemplate}">
> <ItemsControl.ItemsPanel>
> <ItemsPanelTemplate>
> <Canvas />
> </ItemsPanelTemplate>
> </ItemsControl.ItemsPanel>
> </ItemsControl>
>
> </UserControl>
>
> I've spent a huge amount of time trying to get this to work, without success
> so far. So thank you very much if you can tell me what's wrong with it.

My System SpecsSystem Spec
Old 04-25-2006   #3 (permalink)
jods


 
 

RE: Databinding a list of items into a panel

Thanks for the quick answer! My google-fu is too weak apparently, because
I've looked for such a post but didn't find anything useful...

This blog explains and solves exactly the problem that I'm experiencing.

Regards,
jods
My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Some Control Panel items have gone missing Vista General
missing items at control panel General Discussion
cannot access certain control panel items Vista General
Remove items from Control Panel? Vista General
Can't open items in control panel Vista account administration


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