Positioning ItemsControl elements

Topics: Prism v2 - Silverlight 3
Sep 29, 2009 at 11:59 PM
Edited Sep 30, 2009 at 12:01 AM


I am trying to control the position of view items bound to an ItemsControl. Each item has an x, y location that should be used for drawing the view.

<ItemsControl Grid.Row="1" x:Name="ImageTable" ItemsSource="{Binding Path=SystemObjectViewItems, Converter={StaticResource UIElementWrapper}}">










                        <ContentPresenter Content="{Binding Path=Value.View}"/>






<StackPanel x:Name="Stack">

            <TextBlock Text="{Binding Path=SystemObject.Name}"/>

            <TextBlock Text="{Binding Path=System.Name}"/>          


ViewObject code behind:

    public partial class SystemObjectView : ISystemObjectView
        public SystemObjectView()

            Stack.SetValue(Canvas.TopProperty, (double)LocY_Screen);

            Stack.SetValue(Canvas.LeftProperty, (double)LocX_Screen);

        public ISystemObjectViewPresentationModel Model

            get { return this.DataContext as ISystemObjectViewPresentationModel; }

            set { this.DataContext = value; }


The stack panel is drawing correctly but it is not at the specified location. It’s at x=0, y=0 no matter what I set  LocY_Screen or LocX_Screen to.

How can I create a view that will contain multiple xaml elements and position it exactly where I want it? The stack panel is only temporary and will be replaced at some point. Is this the right approach?

Thank you in advance.



Sep 30, 2009 at 2:25 PM

Hi Rick,

I have noticed that you are not using any Canvas in the ItemsControl template, but still you are setting the Canvas.TopProperty in the view. If you do use a Canvas in the template, you should make sure the view is a direct child (first child of it), and set the property using this instead of Stack.

If you have any other questions related to this, you might get a better answer in the Silverlight forums, as this is not directly Prism related (since you are not using Regions) and the community is used to answering Silverlight specific questions.

Please let me know if this helps.

Damian Schenkelman

Sep 30, 2009 at 10:22 PM

Thanks Damian. I will experiment some more.

The ItemsControl is in a view attached to a nested region which is why I posted here.

Thanks again.