ContainerBinding for Attached Property

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    30 posts
    Member since:
    Jul 2012

    Posted 12 Apr 2011 Link to this post

    I am trying to use a ContainerBinding to bind to the Canvas.Left and Canvas.Top attached properties.  Here is an example:

            <telerik:ItemsControl ItemsSource="{Binding Parts}"
                                  HorizontalAlignment="Left"
                                  VerticalAlignment="Top"
                                  Width="500"
                                  Height="500">
                <telerik:ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Canvas>
                            <Canvas.Background>
                                <SolidColorBrush Color="White" />
                            </Canvas.Background>
                        </Canvas>
                    </ItemsPanelTemplate>
                </telerik:ItemsControl.ItemsPanel>
                <!--setup container bindings... temp workaround for inability to do setter bindings in SL-->
                <telerik:ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <telerik:ContainerBinding.ContainerBindings>
                            <telerik:ContainerBindingCollection x:Name="ContainerBindings">
                                <telerik:ContainerBinding PropertyName="(Canvas.Left)"
                                                          Binding="{Binding X}" />
                                <telerik:ContainerBinding PropertyName="(Canvas.Top)"
                                                          Binding="{Binding Y}" />
                                <telerik:ContainerBinding PropertyName="Width"
                                                          Binding="{Binding Width}" />
                                <telerik:ContainerBinding PropertyName="Height"
                                                          Binding="{Binding Height}" />
                            </telerik:ContainerBindingCollection>
                        </telerik:ContainerBinding.ContainerBindings>
                        
                        <Grid Background="Orange"/>
                    </DataTemplate>
                </telerik:ItemsControl.ItemTemplate>           
            </telerik:ItemsControl>

    The Width and Height bindings in the ContainerBinding collection are working fine, but the Canvas.Left and Canvas.Top bindings are not working.  

    Can anyone tell me how to get this working?

  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 13 Apr 2011 Link to this post

    Hi Kevin,

    Unfortunately due to some limitations of Silverlight the container bindings do not work with attached properties. Fortunately in Silverlight 5 this problem does not exist, and actually you will not need container bindings at all :)

    Greetings,
    Valeri Hristov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top