This question is locked. New answers and comments are not allowed.
Hi,
I am using a custom control, inherited from RadGridView control. Applied a custom GridViewRowTemplate on grid view row
After applying this template, memory consumption of grid keeps on increasing when we scroll the grid.
Which part of the template is wrong and creating the problem ?
1.
<
Style
x:Key
=
"CommonGridViewRowStyle"
TargetType
=
"gridView:GridViewRow"
>
2.
<
Setter
Property
=
"Template"
Value
=
"{StaticResource CommonGridViewRowTemplate}"
/>
3.
</
Style
>
001.
<
ControlTemplate
x:Key
=
"CommonGridViewRowTemplate"
TargetType
=
"gridView:GridViewRow"
>
002.
<
Border
BorderBrush
=
"{TemplateBinding BorderBrush}"
BorderThickness
=
"{TemplateBinding BorderThickness}"
>
003.
<
VisualStateManager.VisualStateGroups
>
004.
<
VisualStateGroup
x:Name
=
"FocusStates"
>
005.
<
VisualState
x:Name
=
"Unfocused"
/>
006.
<
VisualState
x:Name
=
"Focused"
>
007.
<
Storyboard
>
008.
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"NavigatorIndicator"
Storyboard.TargetProperty
=
"(UIElement.Visibility)"
>
009.
<
DiscreteObjectKeyFrame
KeyTime
=
"0:0:0"
Value
=
"Visible"
/>
010.
</
ObjectAnimationUsingKeyFrames
>
011.
</
Storyboard
>
012.
</
VisualState
>
013.
</
VisualStateGroup
>
014.
<
VisualStateGroup
x:Name
=
"SelectionStates"
>
015.
<
VisualState
x:Name
=
"Unselected"
/>
016.
</
VisualStateGroup
>
017.
<
VisualStateGroup
x:Name
=
"CommonStates"
>
018.
<
VisualState
x:Name
=
"Normal"
/>
019.
<
VisualState
x:Name
=
"MouseOver"
>
020.
<
Storyboard
>
021.
<
ObjectAnimationUsingKeyFrames
Duration
=
"0"
022.
Storyboard.TargetName
=
"Background_Over"
023.
Storyboard.TargetProperty
=
"(UIElement.Visibility)"
>
024.
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
Value
=
"Visible"
/>
025.
</
ObjectAnimationUsingKeyFrames
>
026.
</
Storyboard
>
027.
</
VisualState
>
028.
<
VisualState
x:Name
=
"Selected"
>
029.
<
Storyboard
>
030.
<
ObjectAnimationUsingKeyFrames
Duration
=
"0"
031.
Storyboard.TargetName
=
"Background_Selected"
032.
Storyboard.TargetProperty
=
"(UIElement.Visibility)"
>
033.
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
Value
=
"Visible"
/>
034.
</
ObjectAnimationUsingKeyFrames
>
035.
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"SelectionIndicator"
Storyboard.TargetProperty
=
"Visibility"
>
036.
<
DiscreteObjectKeyFrame
KeyTime
=
"0:0:0"
Value
=
"Visible"
/>
037.
</
ObjectAnimationUsingKeyFrames
>
038.
</
Storyboard
>
039.
</
VisualState
>
040.
</
VisualStateGroup
>
041.
<
VisualStateGroup
x:Name
=
"ValueStates"
>
042.
<
VisualState
x:Name
=
"Valid"
/>
043.
<
VisualState
x:Name
=
"Invalid"
>
044.
<
Storyboard
>
045.
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"Background_Invalid"
Storyboard.TargetProperty
=
"(UIElement.Visibility)"
>
046.
<
DiscreteObjectKeyFrame
KeyTime
=
"0:0:0"
Value
=
"Visible"
/>
047.
</
ObjectAnimationUsingKeyFrames
>
048.
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"ErrorIndicator"
Storyboard.TargetProperty
=
"Visibility"
>
049.
<
DiscreteObjectKeyFrame
KeyTime
=
"0:0:0"
Value
=
"Visible"
/>
050.
</
ObjectAnimationUsingKeyFrames
>
051.
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"EditIndicator"
Storyboard.TargetProperty
=
"Visibility"
>
052.
<
DiscreteObjectKeyFrame
KeyTime
=
"0:0:0"
Value
=
"Collapsed"
/>
053.
</
ObjectAnimationUsingKeyFrames
>
054.
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"NavigatorIndicator"
Storyboard.TargetProperty
=
"Visibility"
>
055.
<
DiscreteObjectKeyFrame
KeyTime
=
"0:0:0"
Value
=
"Collapsed"
/>
056.
</
ObjectAnimationUsingKeyFrames
>
057.
</
Storyboard
>
058.
</
VisualState
>
059.
</
VisualStateGroup
>
060.
<
VisualStateGroup
x:Name
=
"EditStates"
>
061.
<
VisualState
x:Name
=
"ReadOnlyMode"
/>
062.
<
VisualState
x:Name
=
"EditMode"
>
063.
<
Storyboard
>
064.
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"EditIndicator"
Storyboard.TargetProperty
=
"Visibility"
>
065.
<
DiscreteObjectKeyFrame
KeyTime
=
"0:0:0"
Value
=
"Visible"
/>
066.
</
ObjectAnimationUsingKeyFrames
>
067.
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"NavigatorIndicator"
Storyboard.TargetProperty
=
"Visibility"
>
068.
<
DiscreteObjectKeyFrame
KeyTime
=
"0:0:0"
Value
=
"Visible"
/>
069.
</
ObjectAnimationUsingKeyFrames
>
070.
</
Storyboard
>
071.
</
VisualState
>
072.
</
VisualStateGroup
>
073.
</
VisualStateManager.VisualStateGroups
>
074.
075.
<
gridView:SelectiveScrollingGrid
x:Name
=
"grid"
>
076.
077.
078.
<
gridView:SelectiveScrollingGrid.ColumnDefinitions
>
079.
<
ColumnDefinition
Width
=
"Auto"
/>
080.
<
ColumnDefinition
Width
=
"Auto"
/>
081.
<
ColumnDefinition
Width
=
"Auto"
/>
082.
<
ColumnDefinition
Width
=
"*"
/>
083.
</
gridView:SelectiveScrollingGrid.ColumnDefinitions
>
084.
<
gridView:SelectiveScrollingGrid.RowDefinitions
>
085.
<
RowDefinition
Height
=
"*"
/>
086.
<
RowDefinition
Height
=
"Auto"
/>
087.
<
RowDefinition
Height
=
"Auto"
/>
088.
<
RowDefinition
Height
=
"Auto"
/>
089.
</
gridView:SelectiveScrollingGrid.RowDefinitions
>
090.
091.
<
Border
x:Name
=
"SelectionBackground"
092.
Grid.Column
=
"2"
093.
Grid.ColumnSpan
=
"2"
094.
Margin
=
"{TemplateBinding Margin}"
095.
HorizontalAlignment
=
"{TemplateBinding HorizontalContentAlignment}"
096.
VerticalAlignment
=
"{TemplateBinding VerticalContentAlignment}"
097.
Background
=
"{TemplateBinding Background}"
098.
Padding
=
"{TemplateBinding Padding}"
099.
gridView:SelectiveScrollingGrid.SelectiveScrollingClip
=
"True"
/>
100.
<
Border
x:Name
=
"Background_Over"
101.
Grid.Column
=
"2"
102.
Grid.ColumnSpan
=
"2"
103.
Margin
=
"0"
104.
BorderBrush
=
"{StaticResource ItemOuterBorder_Over}"
105.
BorderThickness
=
"0"
106.
CornerRadius
=
"1"
107.
Visibility
=
"Collapsed"
108.
gridView:SelectiveScrollingGrid.SelectiveScrollingClip
=
"True"
>
109.
<
Border
Background
=
"{StaticResource ItemBackground_Over}"
110.
BorderBrush
=
"{StaticResource ItemInnerBorder_Over}"
111.
BorderThickness
=
"0"
/>
112.
</
Border
>
113.
<
Border
x:Name
=
"Background_Selected"
114.
Grid.Column
=
"2"
115.
Grid.ColumnSpan
=
"2"
116.
Margin
=
"0"
117.
BorderBrush
=
"{StaticResource ItemOuterBorder_Selected}"
118.
BorderThickness
=
"0"
119.
CornerRadius
=
"1"
120.
Visibility
=
"Collapsed"
121.
gridView:SelectiveScrollingGrid.SelectiveScrollingClip
=
"True"
>
122.
<
Border
Background
=
"{StaticResource ItemBackground_Selected}"
123.
BorderBrush
=
"{StaticResource ItemInnerBorder_Selected}"
124.
BorderThickness
=
"0"
/>
125.
</
Border
>
126.
<
Border
x:Name
=
"Background_Invalid"
127.
Grid.Column
=
"2"
128.
Grid.ColumnSpan
=
"2"
129.
Margin
=
"0"
130.
BorderBrush
=
"{StaticResource ItemOuterBorder_Invalid}"
131.
BorderThickness
=
"0"
132.
CornerRadius
=
"1"
133.
Visibility
=
"Collapsed"
134.
gridView:SelectiveScrollingGrid.SelectiveScrollingClip
=
"True"
>
135.
<
Border
Background
=
"{StaticResource ItemBackground_Invalid}"
136.
BorderBrush
=
"{StaticResource ItemInnerBorder_Invalid}"
137.
BorderThickness
=
"0"
/>
138.
</
Border
>
139.
<
telerikGrid:GridViewToggleButton
x:Name
=
"PART_HierarchyExpandButton"
140.
Grid.Column
=
"2"
141.
Width
=
"25"
142.
IsChecked="{Binding IsExpanded,
143.
Mode
=
TwoWay
,
144.
RelativeSource={RelativeSource TemplatedParent}}"
145.
IsHitTestVisible="{Binding IsExpandable,
146.
RelativeSource={RelativeSource TemplatedParent}}"
147.
IsTabStop
=
"{TemplateBinding IsTabStop}"
148.
Opacity="{Binding IsExpandable,
149.
Converter={StaticResource BooleanToOpacityConverter},
150.
RelativeSource={RelativeSource TemplatedParent}}"
151.
Visibility="{Binding HasHierarchy,
152.
Converter={StaticResource BooleanToVisibilityConverter},
153.
RelativeSource={RelativeSource TemplatedParent}}"
154.
gridView:SelectiveScrollingGrid.SelectiveScrollingOrientation
=
"Vertical"
155.
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
156.
<
Border
Grid.Column
=
"2"
157.
Visibility="{Binding HasHierarchy,
158.
Converter={StaticResource BooleanToVisibilityConverter},
159.
RelativeSource={RelativeSource TemplatedParent}}"
160.
gridView:SelectiveScrollingGrid.SelectiveScrollingOrientation
=
"Vertical"
/>
161.
<
gridView:DataCellsPresenter
x:Name
=
"PART_DataCellsPresenter"
162.
Grid.Column
=
"3"
163.
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
164.
<
Border
x:Name
=
"PART_RowBorder"
165.
Grid.RowSpan
=
"4"
166.
Grid.Column
=
"1"
167.
Grid.ColumnSpan
=
"4"
168.
VerticalAlignment
=
"Bottom"
169.
BorderBrush
=
"{TemplateBinding HorizontalGridLinesBrush}"
170.
BorderThickness
=
"0 0 1 0"
171.
gridView:SelectiveScrollingGrid.SelectiveScrollingClip
=
"True"
/>
172.
173.
<!-- IMPORTANT!!! Do not change this border thickness (the left border thickness)! It affects hierarchy child grid column alignments! -->
174.
<
Border
Grid.Row
=
"2"
175.
Grid.Column
=
"2"
176.
Grid.ColumnSpan
=
"2"
177.
Background
=
"{StaticResource GridView_HierarchyBackground}"
178.
BorderBrush
=
"{StaticResource ControlOuterBorder}"
179.
BorderThickness
=
"0,5"
180.
Padding
=
"0"
181.
Visibility="{Binding IsExpanded,
182.
Converter={StaticResource BooleanToVisibilityConverter},
183.
RelativeSource={RelativeSource TemplatedParent}}"
184.
gridView:SelectiveScrollingGrid.SelectiveScrollingClip
=
"True"
>
185.
<
ContentPresenter
x:Name
=
"PART_HierarchyChildPresenter"
gridView:SelectiveScrollingGrid.SelectiveScrollingClip
=
"True"
/>
186.
</
Border
>
187.
188.
<
gridView:DetailsPresenter
x:Name
=
"PART_DetailsPresenter"
189.
Grid.Row
=
"1"
190.
Grid.Column
=
"2"
191.
Grid.ColumnSpan
=
"2"
192.
DetailsProvider
=
"{TemplateBinding DetailsProvider}"
193.
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
194.
<
gridView:IndentPresenter
x:Name
=
"PART_IndentPresenter"
195.
Grid.RowSpan
=
"4"
196.
Grid.Column
=
"1"
197.
IndentLevel
=
"{TemplateBinding IndentLevel}"
198.
gridView:SelectiveScrollingGrid.SelectiveScrollingOrientation
=
"Vertical"
199.
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
200.
<
Border
x:Name
=
"PART_IndicatorPresenter"
201.
Grid.RowSpan
=
"3"
202.
Grid.Column
=
"0"
203.
Width
=
"25"
204.
VerticalAlignment
=
"Stretch"
205.
BorderBrush
=
"{StaticResource ControlOuterBorder}"
206.
BorderThickness
=
"0,0,1,1"
207.
Visibility
=
"{TemplateBinding RowIndicatorVisibility}"
208.
gridView:SelectiveScrollingGrid.SelectiveScrollingOrientation
=
"Vertical"
>
209.
<
Border
x:Name
=
"NavigatorIndicatorBackground"
210.
Background
=
"{StaticResource GridView_RowIndicatorCellBackground}"
211.
BorderThickness
=
"0"
>
212.
<
Grid
>
213.
<!-- IMPORTANT! Don't remove following three lines. RadGridView will crash without this three parts. -->
214.
<
Grid
x:Name
=
"NavigatorIndicator"
Visibility
=
"Collapsed"
/>
215.
<
Grid
x:Name
=
"EditIndicator"
Visibility
=
"Collapsed"
/>
216.
<
Grid
x:Name
=
"ErrorIndicator"
Visibility
=
"Collapsed"
/>
217.
218.
<
Grid
x:Name
=
"SelectionIndicator"
219.
Width
=
"11"
220.
Height
=
"11"
221.
HorizontalAlignment
=
"Center"
222.
VerticalAlignment
=
"Center"
223.
Visibility
=
"Collapsed"
>
224.
<
Path
Width
=
"8"
225.
Height
=
"8"
226.
Margin
=
"0"
227.
HorizontalAlignment
=
"Center"
228.
VerticalAlignment
=
"Center"
229.
Data
=
"M0,0 L8,4 L0,8 L0,0"
230.
Fill
=
"{StaticResource GridView_NavigatorIndicatorBackground}"
231.
Stretch
=
"Fill"
/>
232.
</
Grid
>
233.
</
Grid
>
234.
</
Border
>
235.
</
Border
>
236.
</
gridView:SelectiveScrollingGrid
>
237.
238.
</
Border
>
239.
</
ControlTemplate
>