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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:18:30+00:00 2026-05-12T19:18:30+00:00

So I have this Xaml inside a ListBox Item Template: <ListBox.ItemTemplate> <DataTemplate> <Grid Height=22

  • 0

So I have this Xaml inside a ListBox Item Template:

<ListBox.ItemTemplate>
    <DataTemplate>
        <Grid Height="22" Width="Auto">
            <Image Margin="-2,0,0,0" Source="{Binding Path=ADsPath, Converter={StaticResource ImxConverter}}" HorizontalAlignment="Left" Width="22"  />
            <TextBlock Margin="20,3,0,0" Text="{Binding Path=DisplayValue}" Width="Auto" />
            <Rectangle Fill="White" Stroke="White" Margin="-2,0,-2,0.5" VerticalAlignment="Bottom" Height="1" Width="Auto" />
        </Grid>
    </DataTemplate>
</ListBox.ItemTemplate>

The idea is that the rectangle, provides a thin white line across the bottom of the entire ListBox Item; however, with the Xaml above, it only extends as long as the text, not to the full width of the ListBox.

  • 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-12T19:18:30+00:00Added an answer on May 12, 2026 at 7:18 pm

    Setting your width to Auto basically tells it to only be large enough to fit everything inside. I think you need to set your Grid’s HorizontalAlignment to Stretch for it to work properly.

    Edit:

    I did a small sample app. Here’s how I would do what you are trying to do:

    On your actual listbox, I would have the HorizontalContentAlignment property set to Stretch

    and

    I would change your Grid to a DockPanel:

    <ListBox.ItemTemplate>
        <DataTemplate>
            <DockPanel Height="22" HorizontalAlignment="Stretch">
                <Rectangle Fill="White" Stroke="White" Margin="-2,0,-2,0.5" DockPanel.Dock="Bottom" Height="1"/>
                <Image Margin="-2,0,0,0" Height="20" DockPanel.Dock="Left" Width="22"  />
                <TextBlock Margin="20,3,0,0" Text="Daniel Manning" DockPanel.Dock="Left"/>
            </DockPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have XAML similar to this: <ListBox ItemsSource={Binding SearchCriteria, Source={StaticResource model}} SelectionChanged=cboSearchCriterionType_SelectionChanged> <ListBox.ItemTemplate> <DataTemplate>
I have something like this in my xaml: <Grid> <Image Name=image Source=../../Images/DefaultImage.png HorizontalAlignment=Stretch VerticalAlignment=Stretch></Image>
I have the following XAML: <Grid x:Name=root> <Grid.RowDefinitions> <RowDefinition Height=*/> <RowDefinition Height=Auto/> </Grid.RowDefinitions> <Grid.Resources>
I have a ListBox, inside a Grid, inside an Expander. The ListBox is bound
I have the following XAML inside a 4 Row by 2 column grid. The
I have a style for a textblock that is set inside my app.xaml this
I have a xaml names Customer.xaml like this: <Grid x:Name=customview > <StackPanel x:Name=CustomPanel >
the thing that we do in xaml like this <Image Height=136 HorizontalAlignment=Center x:Name=image1 Stretch=Fill
I have a WPF ListBox with a defined DataTemplate. In that template, I have
I have a datagrid nested inside the ItemTemplate of a ListBox. I'm trying to

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.