Here I am adding ComboBox and TextBox in Silverlight DataGrid.
In XAML,
<data:DataGrid x:Name="mydatagrid" Grid.Row="2" Grid.Column="0" AutoGenerateColumns="False" IsReadOnly="True" Height="200" Width="625"
Visibility="Collapsed" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" SelectionMode="Single">
<data:DataGrid.Columns>
<data:DataGridTemplateColumn Header="RATING SCALE" Width="120">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Loaded="cboRatingScale_Loaded" DisplayMemberPath="{Binding assessmentTitle}" Tag="{Binding rid}" x:Name="cboRatingScale" SelectionChanged="cboRatingScale_SelectionChanged" Width="120" Height="25" ></ComboBox>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
<data:DataGridTextColumn Binding="{Binding GroupTitle}" Header="CAPABILITY" Width="100" />
<data:DataGridTextColumn Binding="{Binding GroupDesc}" Header="DEFINITION" Width="100" />
<data:DataGridTextColumn Binding="{Binding Question}" Header="ANCHOR COMPETENCIES" Width="150" />
<data:DataGridTemplateColumn Header="COMMENTS" Width="150" >
<data:DataGridTemplateColumn.CellTemplate >
<DataTemplate >
<TextBox x:Name="txtComments" VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden" Width="200" AcceptsReturn="True" Height="30" Text="{Binding Remarks}" ></TextBox>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
</data:DataGrid.Columns>
</data:DataGrid>
In c#,
mydatagrid.ItemsSource = e.Result;
You can also put DataPager with this, discussed in my previous post.
Thank you for sharing the coding of Silverlight DataGrid. I think this will help mys brother on his research about the different features of data grip he availed last Sunday.
ReplyDelete