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 3286718
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:24:43+00:00 2026-05-17T20:24:43+00:00

<ItemsPanelTemplate x:Key=lbWrapPanelItemsPanelTemplate> <wp:WrapPanel Margin=2 Background=Beige HorizontalAlignment=Stretch> </wp:WrapPanel> </ItemsPanelTemplate> ….. <Grid Background=LightCoral MinWidth=500 MinHeight=500> <Grid.ColumnDefinitions>

  • 0
    <ItemsPanelTemplate x:Key="lbWrapPanelItemsPanelTemplate">
        <wp:WrapPanel Margin="2" Background="Beige" HorizontalAlignment="Stretch">
        </wp:WrapPanel>
    </ItemsPanelTemplate>

…..

<Grid Background="LightCoral" MinWidth="500" MinHeight="500">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="200"></ColumnDefinition>
        <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <sdk:GridSplitter Grid.Column="0" Background="AliceBlue" />

    <StackPanel Grid.Column="0" FlowDirection="LeftToRight">
        <Button Width="40">Left</Button>
        <Button Width="40">Right</Button>
    </StackPanel>

    <Grid Background="Bisque" Grid.Column="1">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="100"></RowDefinition>
        </Grid.RowDefinitions>

        <ListBox ItemsPanel="{StaticResource lbWrapPanelItemsPanelTemplate}" x:Name="bookListBox" HorizontalAlignment="Stretch"  Grid.Row="0" ItemsSource="{Binding Path=BookSource}" ItemTemplate="{StaticResource dirtSimple}"  />

        <wp:WrapPanel Grid.Row="1">
            <Button Width="200" Command="{Binding Path=AddItemCommand}">Bottom</Button>
            <Button Width="200" Command="{Binding ChangeTemplateCommand}" CommandParameter="{StaticResource vmDataTemplate}">White</Button>
            <Button Width="200" Command="{Binding ChangeTemplateCommand}" CommandParameter="{StaticResource vmDataTemplate2}">Lavender</Button>
        </wp:WrapPanel>
    </Grid>

</Grid>

The ListBox works perfectly, except that the (Beige) WrapPanel seems to extend off into infinity. As more items are added to the ListBox, it just scrolls to the right instead of wrapping. If I add a concrete size to the WrapPanel, that causes things to wrap, but (obviously) causes the items in the LB to be shown in a subset of all available space.

Is there a way to tell the WrapPanel to take up all available space and no more?

  • 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-05-17T20:24:44+00:00Added an answer on May 17, 2026 at 8:24 pm

    I always have trouble getting the WrapPanel to work correctly inside ListBoxes (likely something in the template related to the ScrollViewer in it). If you take your code and put it inside an ItemsControl instead of a ListBox you’ll see it work perfectly as-is.

    You can affect the ScrollViewer inside your WrapPanel and force it to wrap:

    <ListBox HorizontalAlignment="Stretch" ItemsSource="{Binding foo}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <tk:WrapPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>
    

    Note the ScrollViewer.HorizontalScrollBarVisibility set on the ListBox – this prevent a horizontal scrollbar, which forces your WrapPanel to wrap.

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

Sidebar

Related Questions

I have a custom panel for a listbox <ItemsPanelTemplate x:Key=FloatPanelTemplate> <Controls:FloatPanel x:Name=CardPanel /> </ItemsPanelTemplate>
<ItemsControl Margin=0,16 ItemsSource={Binding}> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation=Horizontal Margin=8,0,8,18>
I have an <ItemsControl> with a custom <DataTemplate> (and also a custom <ItemsPanelTemplate> that
I created a user control which contains a ListView with a custom ItemsPanelTemplate. <UserControl
I have this code: <ComboBox Width=100 ItemsSource={Binding FontList} x:Name=fontComboFast> <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate>
I have the following xaml: <Border BorderBrush=Black BorderThickness=1.5 CornerRadius=5> <Grid ShowGridLines=True> <Grid.ColumnDefinitions> <ColumnDefinition Width=Auto/>
I'm trying to achieve the equivalent of a WinForms ListView with its View property
I'm trying to bind KeyValuePair Elements from a Dictionary to a ItemsControl. My Dictionary
I have a ListBox with a StackPanel that contains an image and label. <ListBox.ItemsPanel>
I have a ItemsControl and I will like the items to uniformly fill the

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.