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

Binding CarouselItem to member of a Generic List

4 Answers 75 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 02 Dec 2010, 09:22 PM
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. 

4 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 02 Dec 2010, 09:45 PM
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?
0
Maya
Telerik team
answered on 03 Dec 2010, 02:00 PM
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
0
Scott
Top achievements
Rank 1
answered on 03 Dec 2010, 02:47 PM
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}" />
0
Accepted
Maya
Telerik team
answered on 03 Dec 2010, 04:53 PM
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
Tags
Carousel
Asked by
Scott
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
Maya
Telerik team
Share this question
or