i'm trying to bind a carousel with a CarouselDataRecordPresenter.
- When i'm binding with a datatable, it's OK ( detail code see 1))
- When i'm binding with an objet, the carousel have 2 elements but the property Lib of my object CarouselViewModel is not displayed ( detail code see 2).
Remark:
my visual Studio show me a error "Type or property expected " for the Data when i write the Binding Path=Data.CarouselViewModel.Lib
- When i don't use the CarouselDataRecordPresenter, the carousel displays 2 elements with the name of property (LIB) and its Value.
I tried other type of binding like Data[0] or Fields[Lib)..., but it doesn't work.
What's wrong with my binding?
Can you help me?
1) BINDING with DATATABLE
When i bind a carousel with a datatable , the carousel display the item of my row :
In my code behind :
DataTable
dt = new DataTable();
DataColumn dc = new DataColumn("Lib");
dt.Columns.Add(dc);
DataRow dr = dt.NewRow();
dr[
"Lib"] = "Item1";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[
"Lib"] = "Item2";
dt.Rows.Add(dr);
sampleRadCarousel.ItemsSource = dt;
In my Xaml :
<Style TargetType="{x:Type Controls:CarouselDataRecordPresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:CarouselDataRecordPresenter}">
<StackPanel Margin="0,20,0,0" TextElement.FontWeight="Bold">
<Label Content="{Binding Path=Data[Lib]}"/>
<Label Content="test"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2) BINDING MODELVIEW
In code behind
Collection
<CarouselViewModel> ListeCarousel = new Collection<CarouselViewModel>();
CarouselViewModel carouselview = new CarouselViewModel("item1");
ListeCarousel.Add(carouselview);
CarouselViewModel carouselview1 = new CarouselViewModel("item2");
ListeCarousel.Add(carouselview1);
sampleRadCarousel.ItemsSource = ListeCarousel;
In xaml :
<Style TargetType="{x:Type Controls:CarouselDataRecordPresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:CarouselDataRecordPresenter}">
<StackPanel Margin="0,20,0,0" TextElement.FontWeight="Bold">
<Label Content="{Binding Path=Data.CarouselViewModel.Lib}"/>
<Label Content="2"/>
<Label Content="3"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>