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

Custom Item Template and Data Table Binding

2 Answers 322 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Matt Tapia
Top achievements
Rank 1
Matt Tapia asked on 01 Oct 2009, 09:50 PM
I am attempting to create a Custom Item Template for my carousel that is bound to a datatable. The problem is that when I do the below XAML code, it displays System.DataRow.View or something like that instead of the actual data. I think it has something to do with not defining my data type. What should I put in the DataType property for my DataTemplate in the case that it is bound to a datatable?

<Grid.Resources> 
            <DataTemplate DataType="">  
                <Border Background="LightSlateGray" Padding="10">  
                    <Grid> 
                        <Grid.ColumnDefinitions> 
                            <ColumnDefinition Width="60" /> 
                            <ColumnDefinition Width="*" /> 
                        </Grid.ColumnDefinitions> 
                        <Grid.RowDefinitions> 
                            <RowDefinition Height="20" /> 
                            <RowDefinition Height="*" /> 
                        </Grid.RowDefinitions> 
                        <TextBlock Grid.Column="0" Grid.Row="0" Text="DocumentMasterID">  
                            <TextBlock.TextDecorations> 
                                <TextDecoration Location="Underline" /> 
                            </TextBlock.TextDecorations> 
                        </TextBlock> 
                        <TextBlock Grid.Column="0" Grid.Row="1" Text="{Binding Path=Data[DocumentMasterID]}" /> 
                        <TextBlock Grid.Column="1" Grid.Row="0" Text="CleanLeadsID">  
                            <TextBlock.TextDecorations> 
                                <TextDecoration Location="Underline" /> 
                            </TextBlock.TextDecorations> 
                        </TextBlock> 
                        <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=Data[CleanLeadsID]}" /> 
                    </Grid> 
                </Border> 
            </DataTemplate> 
        </Grid.Resources> 

2 Answers, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 02 Oct 2009, 01:08 PM
Hi Matt Tapia,

To be able to use such global DataTemplate you should first disable the automatic generation of presenters by setting RadCarousel.AutoGenerateDataPresenters to false. After that you are free to use any kind of DataTemplate. If your data items are DataRowView you should set up your template as follows:

<Grid.Resources>    
<!--xmlns:systemData="clr-namespace:System.Data;assembly=System.Data"--> 
            <DataTemplate DataType="{x:Type systemData:DataRowView}">     
                <Border Background="LightSlateGray" Padding="10">     
                    <Grid>    
                        <Grid.ColumnDefinitions>    
                            <ColumnDefinition Width="60" />    
                            <ColumnDefinition Width="*" />    
                        </Grid.ColumnDefinitions>    
                        <Grid.RowDefinitions>    
                            <RowDefinition Height="20" />    
                            <RowDefinition Height="*" />    
                        </Grid.RowDefinitions>    
                        <TextBlock Grid.Column="0" Grid.Row="0" Text="DocumentMasterID">     
                            <TextBlock.TextDecorations>    
                                <TextDecoration Location="Underline" />    
                            </TextBlock.TextDecorations>    
                        </TextBlock>    
                        <TextBlock Grid.Column="0" Grid.Row="1" Text="{Binding Path=[DocumentMasterID]}" />    
                        <TextBlock Grid.Column="1" Grid.Row="0" Text="CleanLeadsID">     
                            <TextBlock.TextDecorations>    
                                <TextDecoration Location="Underline" />    
                            </TextBlock.TextDecorations>    
                        </TextBlock>    
                        <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=[CleanLeadsID]}" />    
                    </Grid>    
                </Border>    
            </DataTemplate>    
        </Grid.Resources>   

I hope this is helpful.

Greetings,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Matt Tapia
Top achievements
Rank 1
answered on 02 Oct 2009, 07:09 PM
had to change the data type slightly:

 

 

<DataTemplate DataType="{x:Type Data:DataRowView}">

But other than that it worked great...Thanks!

 

Tags
Carousel
Asked by
Matt Tapia
Top achievements
Rank 1
Answers by
Milan
Telerik team
Matt Tapia
Top achievements
Rank 1
Share this question
or