This question is locked. New answers and comments are not allowed.
Hi,
I'm using a GridView control to display charts and graphs on each row. I want to add scroll bars to the grid and still have the header frozen when the user scrolls down the rows in the grid. The problem I'm having is with the code I have placed in the _Loaded event for the graphs. In the _Loaded event I'm getting the key for the row identity and looking up a value. Based on the value, I'm making some adjustments to the graph. (i.e. If the value is considered "negative" then I swap the Green and Red range brushs on a bullet chart)
An example would be Lost Product. Most manufacturing will want this value low, therefore the client would like the left side of the bullet graph to be green and the right side of the graph to be red.
I've included the code behind below, my problem is when I set the grids ScrollMode property. Without the ScrollMode property set everything works fine, however when I set the scroll mode, the _Loaded event doesn't work correctly. The event isn't fired for every row and when it does fire it is updating the wrong graph in the grid.
Any help would be greatly appreciated.
Thanks!
I'm using a GridView control to display charts and graphs on each row. I want to add scroll bars to the grid and still have the header frozen when the user scrolls down the rows in the grid. The problem I'm having is with the code I have placed in the _Loaded event for the graphs. In the _Loaded event I'm getting the key for the row identity and looking up a value. Based on the value, I'm making some adjustments to the graph. (i.e. If the value is considered "negative" then I swap the Green and Red range brushs on a bullet chart)
An example would be Lost Product. Most manufacturing will want this value low, therefore the client would like the left side of the bullet graph to be green and the right side of the graph to be red.
I've included the code behind below, my problem is when I set the grids ScrollMode property. Without the ScrollMode property set everything works fine, however when I set the scroll mode, the _Loaded event doesn't work correctly. The event isn't fired for every row and when it does fire it is updating the wrong graph in the grid.
Any help would be greatly appreciated.
Thanks!
<
telerik:RadGridView
x:Name
=
"areaGridView"
ScrollMode
=
"Deferred"
AutoGenerateColumns
=
"False"
IsReadOnly
=
"True"
RowIndicatorVisibility
=
"Collapsed"
CanUserFreezeColumns
=
"False"
ItemsSource
=
"{Binding tblDATA_KPIS}"
DataContext
=
"{Binding}"
Grid.RowSpan
=
"2"
AutoExpandGroups
=
"True"
CanUserInsertRows
=
"False"
CanUserDeleteRows
=
"False"
GridLinesVisibility
=
"Horizontal"
HorizontalContentAlignment
=
"Stretch"
VerticalContentAlignment
=
"Stretch"
UseLayoutRounding
=
"True"
FontSize
=
"12"
Foreground
=
"Black"
GroupPanelForeground
=
"Black"
RowActivated
=
"areaGridView_RowActivated"
MouseLeftButtonDown
=
"areaGridView_MouseLeftButtonDown"
Loaded
=
"areaGridView_Loaded"
MouseEnter
=
"areaGridView_MouseEnter"
ShowGroupPanel
=
"False"
ShowGroupFooters
=
"False"
DataLoaded
=
"areaGridView_DataLoaded"
DataLoading
=
"areaGridView_DataLoading"
GotFocus
=
"areaGridView_GotFocus"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding DATANAME}"
Header
=
"Data Point"
Width
=
"124"
TextWrapping
=
"Wrap"
HeaderTextAlignment
=
"Center"
TextAlignment
=
"Center"
Background
=
"LightBlue"
/>
<
telerik:GridViewDataColumn
Header
=
"Most Recent"
Width
=
"288"
HeaderTextAlignment
=
"Center"
TextAlignment
=
"Center"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
Border
BorderThickness
=
"1"
Width
=
"265"
Height
=
"89"
BorderBrush
=
"Gray"
>
<
StackPanel
Orientation
=
"Vertical"
VerticalAlignment
=
"Center"
>
<
telerik:RadHorizontalBulletGraph
ComparativeMeasure
=
"0"
Width
=
"230"
Height
=
"48"
Margin
=
"5,0,5,0"
Name
=
"radHorizontalBulletGraph"
Step
=
"50"
AutoRange
=
"True"
FeaturedMeasure
=
"{Binding LATEST_VALUE}"
Loaded
=
"radHorizontalBulletGraph_Loaded"
>
<
telerik:RadHorizontalBulletGraph.QualitativeRanges
>
<
telerik:QualitativeRange
/>
<
telerik:QualitativeRange
Brush
=
"#EDBE48"
/>
<
telerik:QualitativeRange
/>
</
telerik:RadHorizontalBulletGraph.QualitativeRanges
>
</
telerik:RadHorizontalBulletGraph
>
</
StackPanel
>
</
Border
>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
</
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
private
void
radHorizontalBulletGraph_Loaded(
object
sender, System.Windows.RoutedEventArgs e)
{
RadHorizontalBulletGraph thisChart = sender
as
Telerik.Windows.Controls.RadHorizontalBulletGraph;
if
(thisChart.DataContext !=
null
)
{
string
[] words = thisChart.DataContext.ToString().Split(
':'
);
Guid guidId =
new
Guid(words[1].ToString());
var id = (from k
in
Context.tblDataPoints where k.id == guidId select k).First();
if
(id.IS_NEGATIVE_TYPE)
{
thisChart.QualitativeRanges[0].Brush =
new
SolidColorBrush(Color.FromArgb(255, Convert.ToByte(
"5E"
, 16), Convert.ToByte(
"DD"
, 16), Convert.ToByte(
"89"
, 16)));
thisChart.QualitativeRanges[2].Brush =
new
SolidColorBrush(Color.FromArgb(255, Convert.ToByte(
"E9"
, 16), Convert.ToByte(
"90"
, 16), Convert.ToByte(
"9D"
, 16)));
}
else
{
thisChart.QualitativeRanges[0].Brush =
new
SolidColorBrush(Color.FromArgb(255, Convert.ToByte(
"E9"
, 16), Convert.ToByte(
"90"
, 16), Convert.ToByte(
"9D"
, 16)));
thisChart.QualitativeRanges[2].Brush =
new
SolidColorBrush(Color.FromArgb(255, Convert.ToByte(
"5E"
, 16), Convert.ToByte(
"DD"
, 16), Convert.ToByte(
"89"
, 16)));
}
}
}