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

Dynamically adding items to RotatorItemsCollection

1 Answer 69 Views
TransitionControl
This is a migrated thread and some comments may be shown as answers.
TMLP
Top achievements
Rank 1
TMLP asked on 01 Nov 2011, 05:35 PM
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)

1 Answer, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 02 Nov 2011, 10:26 AM
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 >>

Tags
TransitionControl
Asked by
TMLP
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Share this question
or