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

HowTo: Add Items Programatically to RadCarouselPanel ?

7 Answers 202 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
David Lino
Top achievements
Rank 1
David Lino asked on 13 May 2010, 02:43 PM
Hi,I'm trying to add Items to a RadCarouselPanel through Code, But I'm having trouble...

This is my code:

...
           
            <telerik:RadCarouselPanel Name="imgPicker"  ItemsMovementAnimationDuration="0:0:0.5"
                    ItemsPerPage="11" PathPadding="70,50,70,50" IsOpacityEnabled="True"
                    IsScalingEnabled="True" IsSkewAngleYEnabled="True" Height="100" MinHeight="100" >
                <telerik:RadCarouselPanel.Path>
                    <Path HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill" Data="M 0,300 C0,300 500,300 500,300 " />
                </telerik:RadCarouselPanel.Path>
                <telerik:RadCarouselPanel.SkewAngleYStops>
                    <telerik:PathStopCollection>
                        <telerik:PathStop PathFraction="0.15" Value="-15" />
                        <telerik:PathStop PathFraction="0.45" Value="-15" />
                        <telerik:PathStop PathFraction="0.5" Value="0" />
                        <telerik:PathStop PathFraction="0.55" Value="15" />
                        <telerik:PathStop PathFraction="0.85" Value="15" />
                    </telerik:PathStopCollection>
                </telerik:RadCarouselPanel.SkewAngleYStops>
                <telerik:RadCarouselPanel.ScaleStops>
                    <telerik:PathStopCollection>
                        <telerik:PathStop PathFraction="0.4" Value="1.0" />
                        <telerik:PathStop PathFraction="0.5" Value="1.5" />
                        <telerik:PathStop PathFraction="0.6" Value="1.0" />
                    </telerik:PathStopCollection>
                </telerik:RadCarouselPanel.ScaleStops>
                <telerik:RadCarouselPanel.OpacityStops>
                    <telerik:PathStopCollection>
                        <telerik:PathStop PathFraction="0.0" Value="0.0" />
                        <telerik:PathStop PathFraction="0.1" Value="1.0" />
                        <telerik:PathStop PathFraction="0.9" Value="1.0" />
                        <telerik:PathStop PathFraction="1.0" Value="0.0" />
                    </telerik:PathStopCollection>
                </telerik:RadCarouselPanel.OpacityStops>
            </telerik:RadCarouselPanel>           
...

And my CodeBehind:

public MainWindow ()
        {
            InitializeComponent();
           
            imageList = new List<BitmapImage>();

            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(@"Imgs/OCR1.TIF", UriKind.RelativeOrAbsolute);
            bi.EndInit();
           
            imageList.Add(bi);

            bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(@"Imgs/OCR2.TIF", UriKind.RelativeOrAbsolute);
            bi.EndInit();

            imageList.Add(bi);

            bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(@"Imgs/OCR3.TIF", UriKind.RelativeOrAbsolute);
            bi.EndInit();

            imageList.Add(bi);

            imgPicker.DataContext = imageList;

         
        }

Is this the right way to do this?

My panel is not showing anything =/

7 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 13 May 2010, 03:14 PM
Hi David Lino,

RadCarouselPanel has a Children property which is a collection of all children that are displayed by the panel. You can use the Add method of Children to add items to RadCarouselPanel.


Best wishes,
Milan
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.
0
David Lino
Top achievements
Rank 1
answered on 13 May 2010, 03:24 PM
But I can't add a "BimapImage" to this collection. I Get an exception =/

I Tried something like:

foreach (BitmapImage bim in imageList)
                imgPicker.Children.Add(bim);

But I get this at compile-time:
Error   3   Argument 1: cannot convert from 'System.Windows.Media.Imaging.BitmapImage' to 'System.Windows.UIElement' 

And I tried to cast, but was unsucessful, and doesn't have a method to do this.

Thanks a lot!




0
Milan
Telerik team
answered on 13 May 2010, 03:29 PM
Hi David Lino,

Only UIElements can be added to this collection. You can use Image objects instead of BitMapImage.


All the best,
Milan
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.
0
David Lino
Top achievements
Rank 1
answered on 13 May 2010, 04:17 PM
I Tried to use Images, but I was unsucessful =/

This is my Code:

imageList = new List<Image>();
            
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(@"Imgs/img.TIF", UriKind.RelativeOrAbsolute);
            bi.EndInit();
            imageList.Add(new Image { Source = bi } );

            bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(@"Imgs/img2.TIF", UriKind.RelativeOrAbsolute);
            bi.EndInit();

            imageList.Add(new Image { Source = bi });

            bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(@"Imgs/img3.TIF", UriKind.RelativeOrAbsolute);
            bi.EndInit();

            imageList.Add(new Image { Source = bi });

            foreach (Image bim in imageList)
                imgPicker.Children.Add(bim);

0
Maya
Telerik team
answered on 14 May 2010, 03:54 PM
Hello David Lino,

I am sending you a sample project that achieves the desired result of adding images to RadCarouselPanel through code. 
I hope that helps.


Sincerely yours,
Maya
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.
0
David Lino
Top achievements
Rank 1
answered on 17 May 2010, 02:30 PM
HI, thanks

It worked!

Where can I Find classes documentation, descripting members, properties and events from RADWPF classes like radCarousel? The .chm from the site doesn't have these things =/
0
Accepted
Maya
Telerik team
answered on 17 May 2010, 04:32 PM
Hello David Lino,

You can find detailed information about all RadControls, including RadCarousel, in our online documentation.  Furthermore, here you will find details about the namespaces, members, etc of RadCarousel.

Kind regards,
Maya
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
Carousel
Asked by
David Lino
Top achievements
Rank 1
Answers by
Milan
Telerik team
David Lino
Top achievements
Rank 1
Maya
Telerik team
Share this question
or