Dynamically adding items to RotatorItemsCollection

2 posts, 0 answers
  1. TMLP
    TMLP avatar
    38 posts
    Member since:
    Jul 2009

    Posted 01 Nov 2011 Link to this post

    Hi,

    I am using RadTransitionControl and images are being rotated.

    <telerik:RadTransitionControl x:Name="transitioncontrol"

    local:RotatorExtensions.ItemChangeDelay="0:0:3"

    local:RotatorExtensions.CurrentSelectedIndex="0"

    Duration="0:0:0.33"

    VerticalAlignment="Center"

    HorizontalAlignment="Left"

    Margin="5,5,5,5"

    Height="205" Width="440"

    > 

    <telerik:RadTransitionControl.ContentTemplate>

    <DataTemplate>

    <Border BorderBrush="LightGray" BorderThickness="1">

    <Image x:Name="MainPage_Image_RadTCImage"

    Height="350" HorizontalAlignment="Left" Stretch="Fill" VerticalAlignment="Top" Width="700"

    Source="{Binding}" />

    </Border>

    </DataTemplate>

    </telerik:RadTransitionControl.ContentTemplate>

    <telerik:RadTransitionControl.Transition>

    <telerik:MotionBlurredZoomTransition />

    </telerik:RadTransitionControl.Transition>

    <local:RotatorExtensions.ItemsSource>

    <local:RotatorItemsCollection>

    <sys:String>/BannerRotator;component/Images/image1.jpg</sys:String>

    <sys:String>/BannerRotator;component/Images/image2.jpg</sys:String>

    </local:RotatorItemsCollection>

    </local:RotatorExtensions.ItemsSource>

    </telerik:RadTransitionControl>


    Now, I'd like to add these images dynamically from MainPage.xaml.cs. How do I do that? (I'm refering to this example)
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 02 Nov 2011 Link to this post

    Hi Tmlp,

    What I would suggest you is to use Image in your DataTemplate, bound to the Content of the TransionControl, like you did in the code you sent:

    <telerik:RadTransitionControl.ContentTemplate>
    <DataTemplate>
    <Border BorderBrush="LightGray" BorderThickness="1">
    <Image x:Name="MainPage_Image_RadTCImage"
    Height="350" HorizontalAlignment="Left" Stretch="Fill" VerticalAlignment="Top" Width="700"
    Source="{Binding}" />
    </Border>
    </DataTemplate>
    </telerik:RadTransitionControl.ContentTemplate>
    And in your code-behind you could just change the Content property of the RadTransitionControl. If you are changing your image from code-behind, you don't need to use the extensions, demonstrated in the referred example.

    Hope this helps.

    Greetings,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top