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

Use grid as DataTemplate with TemplateSelector

1 Answer 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jim
Top achievements
Rank 1
Jim asked on 26 Mar 2012, 12:20 PM
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}" />
     </StackPanel>
 </DataTemplate>

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" >
     <telerik:RadGridView
                 HorizontalAlignment="Left"
                 AutoGenerateColumns="False"
                 IsFilteringAllowed="False"
                 ShowInsertRow="True"
                 ShowGroupFooters="False"
                 ShowGroupPanel="False"
                 CanUserSortColumns="False"
                 CanUserInsertRows="True"
                 RowIndicatorVisibility="Collapsed"
                 CanUserDeleteRows="True"
                 VerticalAlignment="Top"
                 ItemsSource="{Binding Path=DatesAndStays}" >
         <telerik:RadGridView.Columns>
             <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" />
         </telerik:RadGridView.Columns>
     </telerik:RadGridView>
 </DataTemplate>



1 Answer, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 26 Mar 2012, 03:25 PM
OK I think would have worked but I have discovered an error in my data 
Corrected that and it now works.

Thanks
Jim
Tags
GridView
Asked by
Jim
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Share this question
or