I am using Telerik's Silverlight RadGridView in my application. Recently i downloaded the RadControls for Silverlight Q1 2010 SP2 and replaced the old assemblies with new one. But after building my project i got the following errors;
- 'Telerik.Windows.Controls.RadGridView' does not contain a definition for 'ItemsControl' and no extension method 'ItemsControl' accepting a first argument of type 'Telerik.Windows.Controls.RadGridView' could be found (are you missing a using directive or an assembly reference?)
- 'Telerik.Windows.Controls.GridView.GridViewRow' does not contain a definition for 'Items' and no extension method 'Items' accepting a first argument of type 'Telerik.Windows.Controls.GridView.GridViewRow' could be found (are you missing a using directive or an assembly reference?)
for (int i = 0; i <
gridview.Items.Count
; i++)
{
var row = (GridViewRow)this.gridview.ItemsControl.ItemsGenerator.GenerateItemAtIndex(i);
GridViewCell secondCell = (GridViewCell)row.Items[1];
RadComboBox
cmb
=
secondCell
.ChildrenOfType<RadComboBox>()[0];
cmb.ItemsSource = query;
cmb.SelectedIndex = 0;
}
Here is the code snippet, where i got these errors. I think ItemsControl and Items property is removed from latest version of Silverlight controls.
Is there any other properties in new version having same functionality of ItemsControl and Items?
Best Regards,
Kaustubh.
10 Answers, 1 is accepted
In the context of improving performance and optimizing memory consumption, we have made a major refactoring to the scrolling and virtualization logic of RadGridView.
This is the reason to lose the properties/methods you have mentioned.
Looking at your code I assume you are trying to set an ItemsSource for a ComboBox in a GridView cell .
I believe we can find a good replacement for your code with the current version of RadGridView.
Can you please share some more details on the entire scenario. What is the final goal you are trying to achieve and I am sure we can think of some good solution.
For example - we may expose the ItemsSource for the combo boxes as a static resource and bind the combo to it directly in XAML .
Once I have your requirements I will gladly gather a small sample for you .
Regards,
Pavel Pavlov
the Telerik team
Hello Pavel.
Thanks for your reply.
Yes, you are right. In my application i am trying to set an ItemsSource for a ComboBox in a GridView cell which is data template. I am retriving data from SharePoint list and binding to the Combo box. I am following this approach because the number of rows in grid view is not fixed. The number of rows depends upon the value selected by user. Below is the approach I am using to create specified number of rows.
var data = from i in Enumerable.Range(0, count)
select new MyObject()
{
ID = "G-" + (i + 1),
};
grid.ItemsSource = data;
Here the value of count may be from 2 to 8, as per selected by user. After then I am creating the cells for each row having the combo box in cell.
try
{
XNamespace ns = "#RowsetSchema";
var query = from x in e.Result.Descendants()
where x.Name == ns + "row"
select x.Attribute("ows_Title").Value.Split(',')[0];
for (int i = 0; i <
count
; i++)
{
var row = (GridViewRow)this.grid.ItemsControl.ItemsGenerator.GenerateItemAtIndex(i);
GridViewCell secondCell = (GridViewCell)row.Items[1];
RadComboBox
cmb
=
secondCell
.ChildrenOfType<RadComboBox>()[0];
cmb.ItemsSource = query;
cmb.SelectedIndex = 0;
}
Here is the XAML of my RadGridview;
<
grid:RadGridView
x:Name
=
"grid"
Margin
=
"190,150,0,0"
RowIndicatorVisibility
=
"Collapsed"
IsReadOnly
=
"True"
AutoGenerateColumns
=
"False"
CanUserFreezeColumns
=
"False"
CanUserResizeColumns
=
"False"
Width
=
"520"
Height
=
"270"
>
<
grid:RadGridView.Columns
>
<
grid:GridViewDataColumn
x:Name
=
"gaugeColumn"
Header
=
"Gauges"
HeaderTextAlignment
=
"Center"
Width
=
"150"
DataMemberBinding
=
"{Binding ID}"
TextAlignment
=
"Center"
/>
<
grid:GridViewDataColumn
x:Name
=
"measureColumn"
HeaderText
=
"Measures"
HeaderTextAlignment
=
"Center"
Width
=
"200"
>
<
grid:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
telerikInput:RadComboBox
x:Name
=
"cbMeasures"
SelectedIndex
=
"0"
ItemsSource
=
"{Binding Measures}"
>
</
telerikInput:RadComboBox
>
</
DataTemplate
>
</
grid:GridViewDataColumn.CellTemplate
>
</
grid:GridViewDataColumn
>
</
grid:RadGridView.Columns
>
</
grid:RadGridView
>
Waiting for your response.
Many Thanks,
Kaustubh.
Thank you
Chetan
Instead of using the itemcontainer generator to obtain a row,
you can subscribe to the RowLoaded event and set the ItemsSource there . Each time a row is loaded , within the event handler you may set its items source .
This is the recommended way.
Kind regards,
Pavel Pavlov
the Telerik team
I have same problem. i did not find the "ItemsControl" property for RadGridview. So how can i get the perticular GridviewCell for the Radgridview in code behind after the control loading?
My requirement is setting the tooltip for a perticular cell according to business rule.
Thanks & Best Regards,
Anita Sahu
The better approach in your case is to use ToolTipTemplateSelectors, you may check this demo.
Vanya Pavlova
the Telerik team
Thanks for your quick response.
But my requirement is like below code in the current version of the telerik which is not supporting "ItemsControl" property. I dont need the tooltip binding per each cell column wise , i want the tooltip for a pericular cell through the row and column index.
public void SetCellTooltip(int rowindex, int columnindex,string tooltip)
{
var row = (GridViewRow)this.gridview.ItemsControl.ItemsGenerator.GenerateItemAtIndex(rowindex);
GridViewCell Cell = (GridViewCell)row.Items[columnindex];
ToolTipService.SetToolTip(Cell, tooltip);
}
Best Reagards,
Anita Sahu
I tried out RadGridView scroll sample in two different versions (2009.2.701.1020 and 2012.2.912.1050). What my requirement is to scroll two grid synchronously in horizontal direction, the sample work fine in 2009.2.701.1020 but some event and methods missing in 2012.2.912.1050, which make it difficult to achieve it. I enclosed sample project which i obtained from telerik. Help me to achieve the same functionality in 2012.2.912.1050.
Functionality not available in 2012:
1. this.RadGridView1.ItemsControl.Loaded // ItemsControl not available in 2012
2. void verticalScrollBar1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
this.RadGridView2.ItemsControl.VirtualizingPanel.SetVerticalOffset(e.NewValue);
}
I Enclosed sample image with it. Thanks
Thanks,
Randy
I would suggest you to check this github demo for an example on how to scroll two GridViews simultaneously.
I hope this helps.
Regards,
Yoan
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>