Binding CarouselItem to member of a Generic List

5 posts, 1 answers
  1. Scott
    Scott avatar
    42 posts
    Member since:
    Oct 2007

    Posted 02 Dec 2010 Link to this post

    I am binding my RadCarousel to a Generic List and cannot get my binding setup correctly. I have the following XAML for my CarouselDataRecordPresenter and this is where my binding is setup:

    SceneCarousel.xaml
    <Style TargetType="{x:Type telerik:CarouselDataRecordPresenter}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type telerik:CarouselDataRecordPresenter}">
                    <carousel:CarouselItem DataItem="{Binding Path=CarouselItems}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    Below that, my Carousel is setup like so: 
    SceneCarousel.xaml
    <telerik:RadCarousel Name="Scenes" Background="Transparent" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled" Loaded="LoadCarousel">
        <telerik:RadCarousel.ItemsPanel>
            <ItemsPanelTemplate>
                <telerik:RadCarouselPanel AutoLoadItems="false" ItemsPerPage="5" TopContainerChanged="RadCarouselPanel_TopContainerChanged" />
            </ItemsPanelTemplate>
        </telerik:RadCarousel.ItemsPanel>
    </telerik:RadCarousel>

    I am trying to bind to a List<CarouselDataItem> which is this class:
    CarouselDataItem.cs
    public class CarouselDataItem
    {
        public SceneReference Reference { get; set; }
        public string ImagePath { get; set; }
        public Stretch ImageStretch { get; set; }
        public HorizontalAlignment TitleAlignment { get; set; }
        public Visibility ShowDeleteButton { get; set; }
        public bool AddScene { get; set; }
    }

    My issue is getting the DataItem to pass to my CarouselItem UserControl because I don't know how to setup the binding. Whatever I need to put in place of "{Binding Path=CarouselItems}", I can't figure out because it always comes up NULL in my CarouselItem UserControl. 
  2. Scott
    Scott avatar
    42 posts
    Member since:
    Oct 2007

    Posted 02 Dec 2010 Link to this post

    I forgot to mention that in SceneCarousel.xaml.cs, my List is named CarouselItems and that's why I am trying to bind to "CarouselItems".

    Any thoughts?
  3. UI for WPF is Visual Studio 2017 Ready
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 03 Dec 2010 Link to this post

    Hi Scott,

    Please take a look at our online documentation following up the steps for  taking advantage of the CarouselDataRecordPresenter and how to bind the properties of your business object to the corresponding elements.

    Regards,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  5. Scott
    Scott avatar
    42 posts
    Member since:
    Oct 2007

    Posted 03 Dec 2010 Link to this post

    Maya,
    With all due respect, your online documentation for the RadCarousel control is absolutely useless. I've learned very little in reading every word of it and have actually found more use out of your WPF Demos. For example, this page, the "Getting Started" page for the Carousel Control:

    http://www.telerik.com/help/wpf/carousel-getting-started.html

    Is completely blank and has been for about 9 months since I first used the feedback feature to notify your team. 

    Now, my documentation rant aside, I have all of my bindings setup correctly in my UserControl, my problem is that I am trying to pass members of the List<CarouselDataItem> (the Generic List is named CarouselDataItems in SceneCarousel.xaml.cs) to the UserControl for binding, but the property DataItem always comes up NULL in the UserControl. As described, I just don't know what to put in the following line to pass the individual members of the List to the UserControl via it's DataItem property that I have exposed (DataItem is of type CarouselDataItem):

    <carousel:CarouselItem DataItem="{Binding Path=CarouselItems}" />
  6. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 03 Dec 2010 Link to this post

    Hi Scott,

    Following up your scenario, I have prepared a small application for demonstrating a possible approach to achieve it. Basically, you cannot bind the CarouselItem to a collection, you need to use the properties of your business object.
    Let me know if you need any further assistance.
     

    Regards,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
Back to Top
UI for WPF is Visual Studio 2017 Ready