Use grid as DataTemplate with TemplateSelector

2 posts, 0 answers
  1. Jim
    Jim avatar
    68 posts
    Member since:
    Apr 2011

    Posted 26 Mar 2012 Link to this post

    I have a radgridview which display rows.
    Part of the row data depends on a column
    Depending on the column the data may be single item or could be a collection.
    I am using a TemplateSelector 
    The single items work OK and show the relevant data, see example code below

    <DataTemplate x:Name="Template7" >
         <StackPanel Orientation="Horizontal" Margin="10,10,10,10">
             <TextBlock Text="Restricted days: Mon " />
             <CheckBox IsChecked="{Binding RestrictedDays.Monday, Mode=TwoWay}" />
             <TextBlock Text="Tue " />
             <CheckBox IsChecked="{Binding RestrictedDays.Tuesday, Mode=TwoWay}" />
             <TextBlock Text="Wed " />
             <CheckBox IsChecked="{Binding RestrictedDays.Wednesday, Mode=TwoWay}" />
             <TextBlock Text="Thu " />
             <CheckBox IsChecked="{Binding RestrictedDays.Thursday, Mode=TwoWay}" />
             <TextBlock Text="Fri " />
             <CheckBox IsChecked="{Binding RestrictedDays.Friday, Mode=TwoWay}" />
             <TextBlock Text="Sat " />
             <CheckBox IsChecked="{Binding RestrictedDays.Saturday, Mode=TwoWay}" />
             <TextBlock Text="Sun " />
             <CheckBox IsChecked="{Binding RestrictedDays.Sunday, Mode=TwoWay}" />

    However for the collection the grid appears but no data, see code below.
    Is this possible and if so how should I bind the data for the datatemplate grid ??

    Thanks Jim

    <DataTemplate x:Name="Template9" >
                     ItemsSource="{Binding Path=DatesAndStays}" >
                 <telerik:GridViewDataColumn DataMemberBinding="{Binding Date, Mode=TwoWay,StringFormat='dd MMM yyyy'}" Header="Date" />
                 <telerik:GridViewDataColumn DataMemberBinding="{Binding MinDur, Mode=TwoWay}" Header="MinDur" />
                 <telerik:GridViewDataColumn DataMemberBinding="{Binding MaxDur, Mode=TwoWay}" Header="MaxDur" />

  2. Jim
    Jim avatar
    68 posts
    Member since:
    Apr 2011

    Posted 26 Mar 2012 Link to this post

    OK I think would have worked but I have discovered an error in my data 
    Corrected that and it now works.

Back to Top