RadCarousel not showing items correctly

4 posts, 0 answers
  1. David Lino
    David Lino avatar
    13 posts
    Member since:
    Apr 2010

    Posted 19 May 2010 Link to this post

    Hi.
    I'm using the RadCarousel Control.
    I have a List<BitmapImage> and when I add a BitmapImage to this list, I add a Image, with the BitmapImage as source to the RadCarousel.Items

    But, instead of showing the actual image. It's showing a dot.

    I've tryed to attach a sample project that reproduces my problem but I couldn't.
    So follows my code:

    XAML:
    <Window x:Class="radcarouseltest.MainWindow" 
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
            Title="MainWindow" Height="350" Width="525" 
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        <StackPanel> 
            <telerik:RadCarousel Name="carousel" FlowDirection="LeftToRight" VerticalAlignment="Center"  
                                 HorizontalAlignment="Center" HorizontalScrollBarVisibility="Disabled"  /> 
            <Button Content="LoadImages" Click="Button_Click" /> 
        </StackPanel> 
    </Window> 
     

    CS:
    using System; 
    using System.Collections.Generic; 
    using System.Windows; 
    using System.Windows.Controls; 
    using System.Windows.Media.Imaging; 
    using Microsoft.Win32; 
     
    namespace radcarouseltest 
        /// <summary> 
        /// Interaction logic for MainWindow.xaml 
        /// </summary> 
        public partial class MainWindow : Window 
        { 
            private const String ExtensionFilter = "(*.jpg)|*.jpg|(*.gif)|*.gif|(*.png)|*.png|(*.tif)|*.tif|(*.tiff)|*.tiff"
            private List<BitmapImage> imageList; 
            public MainWindow() 
            { 
                InitializeComponent(); 
                imageList = new List<BitmapImage>(); 
            } 
     
            private void Button_Click(object sender, RoutedEventArgs e) 
            { 
                OpenFileDialog dialog = new OpenFileDialog { RestoreDirectory = true, Filter = ExtensionFilter, Multiselect = true }; 
                if (dialog.ShowDialog() == true
                { 
                    foreach (string fileName in dialog.FileNames) 
                    { 
                        BitmapImage myImage = new BitmapImage(new Uri(fileName, UriKind.Relative)); 
                        imageList.Add(myImage); 
                        updateCarousel(); 
                        carousel.SelectedItem = carousel.Items[imageList.Count -1 ]; 
                         
                    } 
                } 
            } 
     
            private void updateCarousel() 
            { 
                carousel.Items.Clear(); 
                foreach (BitmapImage img in imageList) 
                { 
                    Image myImage = new Image(); 
                    myImage.Source = img; 
     
                    carousel.Items.Add(myImage); 
                } 
            } 
        } 
     

    Thanks
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 19 May 2010 Link to this post

    Hello David Lino,

    In your case it will be probably better (and easier) to use RadCarouselPanel. Otherwise, you will have to create DataTemplates in RadCarousel in order to show the images.
    RadCarouselPanel has a Children property which is a collection of all children that are displayed by the panel and you can use the Add () method of Children to insert items. However, this collection accepts only UI Elements, thus obliging you to use Images, for example, instead of Bitmap Images. 
    I am sending you a sample project that shows how to add Images in RadCarouselPanel. 

    I hope that helps. 

    PS: You are allowed to attach project files only when sending a support ticket. 

    All the best,
    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. David Lino
    David Lino avatar
    13 posts
    Member since:
    Apr 2010

    Posted 19 May 2010 Link to this post

    The problem is that I want to use other features available only on RadCarousel, like SelectedItem property and so one.

    Is there a way to insert Image on a radCarousel?

    Can you give me a snippet of code showing how to create the DataTemplates  to show a single image like these?

    Thanks
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 21 May 2010 Link to this post

    Hi David Lino,

    I have re-coded the sample project so that it is using RadCarousel. I hope that meets your requirements. Still, if you have more questions, feel free to contact to us.
    Furthermore, you may find additional information on how to style your carousel in our online documentation


    Greetings,
    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.
Back to Top