Hi there,
In my silverlight application, I use a lot of gridViews and DataForms with DataTemplates, like this example:
<telerik:RadGridView x:Name="grdMensagens" Margin="0 5 0 0" Visibility="{Binding Path=DataContext.VerGridAssuntosReuniao,ElementName=LayoutRoot}"
ItemsSource="{Binding Path=DataContext.OCAssuntosReuniao,ElementName=LayoutRoot}"
SelectedItem="{Binding Path=DataContext.AssuntoSeleccionado,Mode=TwoWay,ElementName=LayoutRoot}"
BorderThickness="0"
Width="Auto" Height="330" MaxHeight="335" Grid.ColumnSpan="3" RowHeight="15"
AutoGenerateColumns="False" IsReadOnly="True"
ShowGroupPanel="False" ShowColumnFooters="False" RowIndicatorVisibility="Collapsed"
LoadingRowDetails="grdMensagens_LoadingRowDetails"
Cursor="Hand">
<swi:Interaction.Triggers>
<swi:EventTrigger EventName="Loaded">
<esi:CallDataMethod Method="grdAssuntos_Loaded"/>
</swi:EventTrigger>
</swi:Interaction.Triggers>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Assunto" Width="0.9*">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<telerikHtml:HtmlDataProvider x:Name="HtmlProvider" RichTextBox="{Binding ElementName=LeitorTemplateNotif}" Html="{Binding ConteudoProp}"/>
<telerik:RadRichTextBox Height="Auto" HorizontalAlignment="Stretch" Margin="0" FontFamily="Arial" FontSize="10" BorderBrush="Transparent" BorderThickness="0" Background="Transparent" IsImageMiniToolBarEnabled="False" Name="LeitorTemplateNotif" IsReadOnly="True" Visibility="Visible" telerik:StyleManager.Theme="{Binding Path=DataContext.Tema, ElementName=LayoutRoot}" Loaded="ProcessadorTextoSGA_Loaded"/>
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Anexos" Width="0.1*">
<telerik:GridViewColumn.CellStyle>
<Style TargetType="telerik:GridViewCell">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="telerik:GridViewCell">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Margin="1" Height="25" Width="25" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Command="{Binding Path=DataContext.CmdVerAnexos,ElementName=LayoutRoot}" CommandParameter="{Binding IdProp}" Style="{StaticResource GlassButton}" ToolTipService.ToolTip="Clique para ver os detalhes do documento">
<StackPanel HorizontalAlignment="Left" Width="Auto" Height="Auto" Orientation="Horizontal">
<Image Grid.Column="0" HorizontalAlignment="Stretch" Source="{Binding Icone}" Height="20" Width="20" Stretch="Fill"/>
</StackPanel>
</Button>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</telerik:GridViewColumn.CellStyle>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</StackPanel>
</telerik:RadTabItem.Content>
</telerik:RadTabItem>
And my application have a lot of leaks of memory, if I let the application running for 1 hour the memory used by my application goes unitl 1GB!!!! This is a lot for one simple web application!!!
So I decide investigate and read that DataTemplates are not collected by GC.
So, what is the solution? This is very important. I also read that this behaviour doesn´t occure in Silverlight 3...
Please, i need help here.
Thanks in advance.
Nelson Silva
In my silverlight application, I use a lot of gridViews and DataForms with DataTemplates, like this example:
<telerik:RadGridView x:Name="grdMensagens" Margin="0 5 0 0" Visibility="{Binding Path=DataContext.VerGridAssuntosReuniao,ElementName=LayoutRoot}"
ItemsSource="{Binding Path=DataContext.OCAssuntosReuniao,ElementName=LayoutRoot}"
SelectedItem="{Binding Path=DataContext.AssuntoSeleccionado,Mode=TwoWay,ElementName=LayoutRoot}"
BorderThickness="0"
Width="Auto" Height="330" MaxHeight="335" Grid.ColumnSpan="3" RowHeight="15"
AutoGenerateColumns="False" IsReadOnly="True"
ShowGroupPanel="False" ShowColumnFooters="False" RowIndicatorVisibility="Collapsed"
LoadingRowDetails="grdMensagens_LoadingRowDetails"
Cursor="Hand">
<swi:Interaction.Triggers>
<swi:EventTrigger EventName="Loaded">
<esi:CallDataMethod Method="grdAssuntos_Loaded"/>
</swi:EventTrigger>
</swi:Interaction.Triggers>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Assunto" Width="0.9*">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<telerikHtml:HtmlDataProvider x:Name="HtmlProvider" RichTextBox="{Binding ElementName=LeitorTemplateNotif}" Html="{Binding ConteudoProp}"/>
<telerik:RadRichTextBox Height="Auto" HorizontalAlignment="Stretch" Margin="0" FontFamily="Arial" FontSize="10" BorderBrush="Transparent" BorderThickness="0" Background="Transparent" IsImageMiniToolBarEnabled="False" Name="LeitorTemplateNotif" IsReadOnly="True" Visibility="Visible" telerik:StyleManager.Theme="{Binding Path=DataContext.Tema, ElementName=LayoutRoot}" Loaded="ProcessadorTextoSGA_Loaded"/>
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Anexos" Width="0.1*">
<telerik:GridViewColumn.CellStyle>
<Style TargetType="telerik:GridViewCell">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="telerik:GridViewCell">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Margin="1" Height="25" Width="25" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Command="{Binding Path=DataContext.CmdVerAnexos,ElementName=LayoutRoot}" CommandParameter="{Binding IdProp}" Style="{StaticResource GlassButton}" ToolTipService.ToolTip="Clique para ver os detalhes do documento">
<StackPanel HorizontalAlignment="Left" Width="Auto" Height="Auto" Orientation="Horizontal">
<Image Grid.Column="0" HorizontalAlignment="Stretch" Source="{Binding Icone}" Height="20" Width="20" Stretch="Fill"/>
</StackPanel>
</Button>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</telerik:GridViewColumn.CellStyle>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</StackPanel>
</telerik:RadTabItem.Content>
</telerik:RadTabItem>
And my application have a lot of leaks of memory, if I let the application running for 1 hour the memory used by my application goes unitl 1GB!!!! This is a lot for one simple web application!!!
So I decide investigate and read that DataTemplates are not collected by GC.
So, what is the solution? This is very important. I also read that this behaviour doesn´t occure in Silverlight 3...
Please, i need help here.
Thanks in advance.
Nelson Silva