Custom Item Template and Data Table Binding

3 posts, 1 answers
  1. Matt Tapia
    Matt Tapia avatar
    18 posts
    Member since:
    Jul 2009

    Posted 01 Oct 2009 Link to this post

    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. Answer
    Milan
    Admin
    Milan avatar
    1989 posts

    Posted 02 Oct 2009 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Matt Tapia
    Matt Tapia avatar
    18 posts
    Member since:
    Jul 2009

    Posted 02 Oct 2009 Link to this post

    had to change the data type slightly:

     

     

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

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

     

Back to Top