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

  • Home
  • SEARCH
  • 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 8605451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:50:04+00:00 2026-06-12T02:50:04+00:00

Using a template for a custom control deriving from ListBox causes filtering of ItemSource

  • 0

Using a template for a custom control deriving from ListBox causes filtering of ItemSource to become slow. The filtering is done in the get of the ItemSource that the control is bound to. This problem is not present when a normal ListBox is used, so why should it be any different for a custom ListBox?

Filtering:

public IEnumerable<LibraryViewModel> Libraries {
    get {
        if (!string.IsNullOrEmpty(this.LibrarySearchString))
            return _libraries.Where(lib => IsLibraryMatch(lib, this.LibrarySearchString));
        else
            return _libraries.OrderBy(lib => !lib.IsFavourite);
    }
}  

Using the control:

<con:FilterListBox Grid.Row="1"
                   ItemsSource="{Binding Libraries}"
                   SelectedItem="{Binding SelectedLibrary}"
                   ItemTemplate="{StaticResource  
                                  LibraryItemTemplate}"                           
                   SearchString="{Binding LibrarySearchString, Mode=TwoWay}"
                   IsSearching="False"
                   Margin="4"/>

The control template:

<Style x:Key="{x:Type con:FilterListBox}" TargetType="{x:Type con:FilterListBox}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type con:FilterListBox}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>

                    <DockPanel Grid.Row="0">
                        <TextBlock Text="Search"
                                    VerticalAlignment="Center"/>
                        <TextBox Text="{Binding RelativeSource={RelativeSource TemplatedParent},
                                                Path=SearchString,
                                                UpdateSourceTrigger=PropertyChanged}"
                                 Margin="4,0,0,0"/>
                    </DockPanel>

                    <ScrollViewer Grid.Row="1" CanContentScroll="True">
                        <StackPanel IsItemsHost="True"
                                    HorizontalAlignment="Stretch"/>
                    </ScrollViewer>

                    <TextBlock Grid.Row="1"
                               Text="Searching..."
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               Visibility="{Binding RelativeSource={RelativeSource TemplatedParent},
                                                    Path=IsSearching,
                                                    Converter={StaticResource CollapsedIfFalseConverter}}"/>
                </Grid>

            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Thanks for any help.

  • 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-12T02:50:06+00:00Added an answer on June 12, 2026 at 2:50 am

    The slow behavior of your FilterListBox may come with an Virtualization issue. You replaced the ItemsHost of the ListBox with a simple StackPanel. By default, the ListBox uses a VirtualizingStackPanel, which virtualizes the Items whenever possible. See the default ListBox Template as a reference. If you have a simple StackPanel as ItemsPresenter, the ListBox has to re-render every item when your filter changes. Depending on the number of items, this can cause your slow behavior. Try to use the default itemshost instead. You should also know, that virtualization is only possible with ‘simple’ items (same Height for every item basically).

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

Sidebar

Related Questions

I'm using Microsoft Windows Phone 7 Tools Beta. I have a custom control that
I have a class derived from slider which uses a custom control template and
Background I have a custom control that inherits from a TreeView and is modified
When using custom template for Login control , if we add control with ID
Im using a Custom NestedRepeater Control for ASP.NET which can be found on code
I am using Telerik's RadPanelBar and customizing it by deriving the class from RadPanelbar.
I have created a custom TaskButton control that takes an image and text. The
Here's the situation: I have a custom TextBox control that contains multiple other TextBox
There is a custom control called TestCustomControl, it inherits from Control and it has
I'd like to add my custom control into a template column of data grid.

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.