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

Binding doesn't works

9 Answers 175 Views
TransitionControl
This is a migrated thread and some comments may be shown as answers.
Igor Macedo
Top achievements
Rank 2
Igor Macedo asked on 17 Feb 2011, 01:35 PM
Hello all,

I need a little help with TransitionControl. Why this *simple* example doesn't works?

<Grid x:Name="LayoutRoot" Background="White">
    <ListBox x:Name="MyListBox" Background="#FFFFFDD5" Width="200" HorizontalAlignment="Left">
        <TextBlock Text="Test One" />
        <TextBlock Text="Test Two" />
        <TextBlock Text="Test Tree" />
    </ListBox>
    <StackPanel Background="#46FF0000"  Margin="250,50,50,50">
        <telerik:RadTransitionControl x:Name="radTransitionControl"
                           Content="{Binding SelectedItem, ElementName=MyListBox}" Height="30" FontSize="21.333">
            <telerik:RadTransitionControl.ContentTemplate>
                <DataTemplate>
                    <StackPanel Background="Black">
                        <TextBlock Text="{Binding Text}" Foreground="Yellow" TextAlignment="Center"/>
                    </StackPanel>
                </DataTemplate>
            </telerik:RadTransitionControl.ContentTemplate>
        </telerik:RadTransitionControl>
    </StackPanel>
</Grid>


Thanks in advance

Igor

9 Answers, 1 is accepted

Sort by
0
Waleed Seada
Top achievements
Rank 2
answered on 18 Feb 2011, 06:50 PM
Hello Igor,

I guess beacause you forgot to add the Transition part :

<telerik:RadTransitionControl.Transition >
    <TransitionEffects:WaveTransition />
</telerik:RadTransitionControl.Transition>

Just before the closing tag of RadTransition control (</telerik:RadTransitionControl>)

Best regards
Waleed
0
Igor Macedo
Top achievements
Rank 2
answered on 19 Feb 2011, 08:52 PM
OMG! Sorry about my mistake, but doesn't works too :(

When I select an item I got the attached error.

Thanks in advance

Igor
0
Waleed Seada
Top achievements
Rank 2
answered on 20 Feb 2011, 12:38 AM
Dear Igor,

I tried your xaml but It gives me an earlier error, which is :
Message: Element is already the child of another element

I am searching for a reason for it

Regards
Waleed
0
Accepted
Waleed Seada
Top achievements
Rank 2
answered on 20 Feb 2011, 01:08 AM
Dear Igor,

Here is a working solution for your problem.

<ListBox x:Name="MyListBox" Background="#FFFFFDD5" Width="200" HorizontalAlignment="Left">
    <TextBlock Text="One"/>
    <TextBlock Text="Two"/>
    <TextBlock Text="Three"/>
</ListBox>
<telerik:RadTransitionControl x:Name="radTRansitionControl"
               Content="{Binding Path=SelectedItem.Text, ElementName=MyListBox}">
    <telerik:RadTransitionControl.ContentTemplate>
        <DataTemplate>
            <StackPanel Background="Black">
                <TextBlock Text="{Binding}" Foreground="Yellow" Width="200"/>
            </StackPanel>
        </DataTemplate>
    </telerik:RadTransitionControl.ContentTemplate>
</telerik:RadTransitionControl>

Have a look at the bold line : content="{Binding Path=SelectedItem.Text, ....." nad also the binding to the Inner Textblock

Best regards
Waleed
0
Igor Macedo
Top achievements
Rank 2
answered on 21 Feb 2011, 01:08 PM
Yess... this works fine :-)

You know if there is any way to bind a control's content? Like a Grid or StackPanel?

Thanks
0
Waleed Seada
Top achievements
Rank 2
answered on 21 Feb 2011, 06:51 PM
Dear Igor,

I am not sure I understood your question.

First you can bing the RadGrid to a CollectionView and then you can subscribe to the CurrentChanged event and do the show.

If you explain exactly what you r up to, I can help...

Regards
Waleed
0
Igor Macedo
Top achievements
Rank 2
answered on 22 Feb 2011, 02:50 AM
Sorry, I wasn't so direct!

Can I use RadTransitionControl to swap between StackPanels?

Something like that:

<ListBox x:Name="MyListBox" Background="#FFFFFDD5" Width="200" HorizontalAlignment="Left">
    <StackPanel><TextBlock Text="One"/></StackPanel>
    <StackPanel><TextBlock Text="Two"/></StackPanel>
    <StackPanel><TextBlock Text="Three"/></StackPanel>
</ListBox>
<telerik:RadTransitionControl x:Name="radTRansitionControl"
               Content="{Binding Path=SelectedItem.Content, ElementName=MyListBox}">
    <telerik:RadTransitionControl.ContentTemplate>
        <DataTemplate>
            <StackPanel Background="Black" Content="{Binding} />
        </DataTemplate>
    </telerik:RadTransitionControl.ContentTemplate>
</telerik:RadTransitionControl>


I know that example doesn't works, but I is possible? I guess I'll get the error about "Element is already the child of another element".

There is an alternative?

Thanks again
0
Accepted
George
Telerik team
answered on 24 Feb 2011, 02:33 PM
Hi Igor,

 
Yes, you are right that you will get the exception. The only way to do is to use one and same DataTemplate for the ListBox.ItemTemplate and for the RadTransitionControl.ContentTemplate. You could bind the RadTransitionControl.Content for the SelectedItem.DataContext of the Listbox.

I hope this helps!

Regards,
George
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Igor Macedo
Top achievements
Rank 2
answered on 24 Feb 2011, 03:56 PM
Hey George,

Thanks for you help... I'll make some tests!

Regards

Igor
Tags
TransitionControl
Asked by
Igor Macedo
Top achievements
Rank 2
Answers by
Waleed Seada
Top achievements
Rank 2
Igor Macedo
Top achievements
Rank 2
George
Telerik team
Share this question
or