Binding doesn't works

10 posts, 2 answers
  1. Igor Macedo
    Igor Macedo avatar
    26 posts
    Member since:
    Jun 2012

    Posted 17 Feb 2011 Link to this post

    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
  2. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 18 Feb 2011 Link to this post

    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
  3. DevCraft banner
  4. Igor Macedo
    Igor Macedo avatar
    26 posts
    Member since:
    Jun 2012

    Posted 19 Feb 2011 Link to this post

    OMG! Sorry about my mistake, but doesn't works too :(

    When I select an item I got the attached error.

    Thanks in advance

    Igor
  5. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 19 Feb 2011 Link to this post

    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
  6. Answer
    Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 19 Feb 2011 Link to this post

    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
  7. Igor Macedo
    Igor Macedo avatar
    26 posts
    Member since:
    Jun 2012

    Posted 21 Feb 2011 Link to this post

    Yess... this works fine :-)

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

    Thanks
  8. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 21 Feb 2011 Link to this post

    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
  9. Igor Macedo
    Igor Macedo avatar
    26 posts
    Member since:
    Jun 2012

    Posted 21 Feb 2011 Link to this post

    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
  10. Answer
    George
    Admin
    George avatar
    1332 posts

    Posted 24 Feb 2011 Link to this post

    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!
  11. Igor Macedo
    Igor Macedo avatar
    26 posts
    Member since:
    Jun 2012

    Posted 24 Feb 2011 Link to this post

    Hey George,

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

    Regards

    Igor
Back to Top
DevCraft banner