This is a migrated thread and some comments may be shown as answers.

ContainerBinding for Attached Property

1 Answer 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 13 Apr 2011, 12:17 AM
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?

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 13 Apr 2011, 08:21 AM

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
Tags
General Discussions
Asked by
Kevin
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or