This question is locked. New answers and comments are not allowed.
I am dynamically generating a RadGridView of variable columns/rows. Each cell contains a text box with 2 converters. But the performance gets really slow when I have around 50 columns X 50 rows. And out right crashes at around 280 columns x 280 rows. Any suggestions? Thanks in advance.
The purpose of the converters is to display either orange or blue depending if the value is positive or negative. And adjust the opacity of the color based on its value.
Our suspicion is that since I'm declaring the converter for each cell each time, it consumes a lot of memory. Is there another way to do it since I can not really use template as I do not have the binding variable until run time.
Code Snippet below: ID', 'string Column Name', 'double[] Values'
Itemsource is a collection of class with 'int
The created columns are returned and added.
The purpose of the converters is to display either orange or blue depending if the value is positive or negative. And adjust the opacity of the color based on its value.
Our suspicion is that since I'm declaring the converter for each cell each time, it consumes a lot of memory. Is there another way to do it since I can not really use template as I do not have the binding variable until run time.
Code Snippet below: ID', 'string Column Name', 'double[] Values'
Itemsource is a collection of class with 'int
<
telerik:RadGridView
AutoGenerateColumns
=
"False"
Name
=
"CorrelationGrid"
CanUserFreezeColumns
=
"False"
VerticalAlignment
=
"Stretch"
RowIndicatorVisibility
=
"Collapsed"
ShowGroupPanel
=
"False"
ShowColumnHeaders
=
"true"
BorderBrush
=
"Transparent"
HorizontalAlignment
=
"Left"
IsReadOnly
=
"True"
EnableColumnVirtualization
=
"True"
EnableRowVirtualization
=
"True"
>
</
telerik:RadGridView
>
protected
GridViewColumn CreateContinuousStatisticColumn(
string
colName,
string
colHeader, Boolean stringFormat,
int
i)
{
StringBuilder CellTemp =
new
StringBuilder();
Style cellStyle = CreateCellStyle();
CellTemp.Append(
"<DataTemplate "
);
CellTemp.Append(
"xmlns='http://schemas.microsoft.com/winfx/"
);
CellTemp.Append(
"2006/xaml/presentation' "
);
CellTemp.Append("xmlns:my='clr-namespace:MyProject;assembly=MyProject' ");
CellTemp.Append(
"xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' >"
);
CellTemp.Append(
"<Grid HorizontalAlignment='Stretch' Margin='0,0,0,0'>"
);
CellTemp.Append(
"<Grid.Resources>"
);
CellTemp.Append(
"<my:PosColorConverter x:Key='GetPosColorConverter'/>"
);
CellTemp.Append(
"<my:NegColorConverter x:Key='GetNegColorConverter'/>"
);
CellTemp.Append(
"</Grid.Resources>"
);
if
(stringFormat)
{
CellTemp.Append(
"<Border HorizontalAlignment='Stretch' VerticalAlignment='Stretch' Background='#47A4D0' BorderThickness='0' Opacity='{Binding Path="
);
CellTemp.Append(
"Values["
+ i.ToString(CultureInfo.InvariantCulture) +
"]"
);
CellTemp.Append(
", Mode=OneWay, Converter={StaticResource GetPosColorConverter}}'/>"
);
CellTemp.Append(
"<Border HorizontalAlignment='Stretch' VerticalAlignment='Stretch' Background='#FF6A00' BorderThickness='0' Opacity='{Binding Path="
);
CellTemp.Append(
"Values["
+ i.ToString(CultureInfo.InvariantCulture) +
"], Mode=OneWay, Converter={StaticResource GetNegColorConverter}}'/>"
);
CellTemp.Append(
"<TextBlock Padding='5,2,5,2' Margin='3' VerticalAlignment='Center' HorizontalAlignment='Center' Text='{Binding Path=Values["
+ i.ToString(CultureInfo.InvariantCulture) +
"]"
);
CellTemp.Append(
", StringFormat=n3}' />"
);
}
else
CellTemp.Append(
"<TextBlock Padding='5,2,5,2' Margin='3' VerticalAlignment='Center' HorizontalAlignment='Center' Text='{Binding Path="
+ colName +
"}' />"
);
CellTemp.Append(
"</Grid>"
);
CellTemp.Append(
"</DataTemplate>"
);
return
new
GridViewColumn()
{
IsFilterable =
false
,
IsSortable =
true
,
Header = colHeader,
SortMemberPath = stringFormat ?
"Values["
+ i.ToString(CultureInfo.InvariantCulture) +
"]"
: colName,
UniqueName = colName,
IsReadOnly =
true
,
HeaderTextAlignment = TextAlignment.Center,
CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString()),
CellStyle = cellStyle,
};
}
The created columns are returned and added.