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

Databinding a list of items into a panel

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 04-24-2006   #1 (permalink)
jods
Guest


 

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
Guest


 

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
Guest


 

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

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot access certain control panel items pvt_pilot Vista General 0 01-22-2008 09:26 PM
Remove items from Control Panel? Brian Wescombe Vista General 3 01-03-2008 10:18 AM
Recent items list KRK Vista General 5 12-02-2007 06:05 AM
My Control Panel items have disappeared Steven Hanson Vista General 6 10-12-2007 01:20 AM
Can't open items in control panel elundquist Vista account administration 1 01-02-2007 10:52 AM


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 51