Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:21:38+00:00 2026-06-17T21:21:38+00:00

I have a ListView-Control in XAML: <ListView x:Name=conversationContent Grid.Column=2 Margin=20,0,0,20 FontFamily=Global User Interface >

  • 0

I have a ListView-Control in XAML:

<ListView x:Name="conversationContent" Grid.Column="2" Margin="20,0,0,20" FontFamily="Global User Interface" >
    <ListView.Resources>
        <CollectionViewSource x:Name="conversationContentSource" IsSourceGrouped="False" />
        <DataTemplate x:Key="DataTemplate1">
            <Grid HorizontalAlignment="Stretch">
                <Border x:Name="messageBorder" BorderBrush="Black" BorderThickness="1" Margin="0" CornerRadius="2" VerticalAlignment="Center" HorizontalAlignment="{Binding MTY, Converter={StaticResource messageAlignment}}" Child="{Binding MSG, Converter={StaticResource messageToRTF}}" />
            </Grid>
        </DataTemplate>
    </ListView.Resources>
    <ListView.ItemsSource>
        <Binding Mode="OneWay" Source="{StaticResource conversationContentSource}"/>
    </ListView.ItemsSource>
</ListView>

The CollectionViewSource is being set to some ObservableCollection<Message> at runtime from code behind.

Every Item in the ObservableCollection is being parsed by a Converter, it translates the complete Message (incl. BB-Codes) to a single RichTextBlock-Element, which contains other UI-Elements.

Sometimes, the CollectionViewSource.Source-Property changes to another ObersableCollection<Message>. When this happens, the ListView-Control builds up the new ItemList and displays it. As far as good.

The Problem is, the old Items are not going to be removed from Memory. Running the GC manually doesn’t change anything here.

I tried to iterate through the old items and delete them before changing the Source.

for (int ix = conversationContent.Items.Count - 1; ix >= 0; ix--) {
    Debug.WriteLine("Type: " + conversationContent.Items.ElementAt(ix));
    if (conversationContent.Items.ElementAt(ix) is RichTextBlock) {
        conversationContent.Items.RemoveAt(ix);
    }
}

But instead of RichTextBlock-Controls, there are only Objects of the type “Message”. Why?

I need to say, some of the generated Elements can contain Canvas-Elements with an update-function, which is being called every 200ms by a timer-event. Can this event-Binding prevent the GC to kill this objects?

I need a way to free up the memory, when the controls are not longer in use.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:21:39+00:00Added an answer on June 17, 2026 at 9:21 pm

    You can and should use a RichTextBlock as your ItemTemplate. Research attached behaviors or attached dependency properties to figure out how to add a property to the RichTextBlock that will convert your BB-code formatted message to RichTextBlock content. You can see an example that adds hyperlinked text to a RichTextBlock in WinRT XAML Toolkit here.

    For investigating memory leaks check this question: How to debug memory leaks in Windows Store apps?

    Most frequent cause of memory leaks I see are event handlers that are never removed – make sure to remove all handlers on your RichTextBlock‘s Unloaded event. Also check if disabling all of your animations (e.g. in your animated emoticons).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a User Control defined like this: XAML: <UserControl> <Grid x:Name=LayoutRoot> <TabControl x:Name=TabControl
I have the following wpf control added to xaml: <ListView Margin=22,80,271,12 Name=listView1 ItemsSource={Binding} />
I have the following xaml which resides in a wpf user control - <Grid>
I have listview control.There is an option to remove selected items.After the user removes
I have a ListView control in XAML. The items are defined by a template
I have a WPF ListView control with a ContextMenu written in XAML Code. With
I have a simple listview, with a grid control. I have bound an object
I have the following XAML/Control Template for a ListViewItem: <Window.Resources> <ControlTemplate x:Key=ItemTemplate TargetType=ListViewItem> <Border
I have a ListView control set up in details mode with 5 columns. It
I have a ListView control on my form set up like this in details

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.