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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:07:33+00:00 2026-05-23T16:07:33+00:00

I am having a problem with getting the listviewitems to size to the space

  • 0

I am having a problem with getting the listviewitems to size to the space available to it in the second column of a grid. I have a ValidationItemError class that can have a long description. This is the DataTemplate xaml for it.

<DataTemplate DataType="{x:Type Models:ValidationItemError}">
    <StackPanel>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="20"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <Ellipse Width="10"
                     Height="10"
                     Margin="5,0,0,0"
                     Fill="Crimson" />
            <TextBlock Text="{Binding ColumnName}"
                       Grid.Column="1"
                       FontWeight="Bold" />
        </Grid>
        <TextBlock Text="{Binding Description}"
                   ToolTip="{Binding Description}"
                   Margin="20,0,0,0"
                   TextWrapping="Wrap" />
    </StackPanel>
</DataTemplate>

The validationItemErrors are grouped into another class ValidationLineItem and this is its DataTemplate

<DataTemplate DataType="{x:Type Models:ValidationLineItem}">
    <StackPanel>
        <Grid Margin="0,10,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="35"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <TextBlock Text="Line"
                       FontSize="16"
                       FontWeight="Bold" />
            <TextBlock Text="{Binding LineNumber}"
                       Margin="5,0,0,0"
                       FontSize="16"
                       Grid.Column="1" />
        </Grid>
        <ItemsControl ItemsSource="{Binding ValidationItems}">
        </ItemsControl>
    </StackPanel>
</DataTemplate>

So basically I have a validationLineItem which stores the linenumber and multiple ValidationItemError/Warnings stored in the ValidationItems property. So now I just bind that data to a listview that is on left column of the grid.

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="75*" />
        <ColumnDefinition Name="GridCell" Width="25*" />
    </Grid.ColumnDefinitions>
    <ScrollViewer Grid.Column="1">
        <ListView ItemsSource="{Binding ValidationItems}"                          
                  SelectedItem="{Binding SelectedValidationItem}"                          
                  SelectionChanged="ListViewSelectionChanged">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="Width"
                            Value="{Binding ElementName=GridCell, Path=Width}" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
    </ScrollViewer>
</Grid>

That all renders fine except for this part

<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="Width"
                Value="{Binding ElementName=GridCell, Path=Width}" />
    </Style>
</ListView.ItemContainerStyle>

The description textblock ignores the width setting and does not wrap like I need it to.
If I manually set the width like

<Setter Property="Width" Value="100" />

instead of

<Setter Property="Width" Value="{Binding ElementName=GridCell, Path=Width}" />

The description textblock wraps as I would like.
Anyone have any ideas? I am sure I’m missing something simple here.

I should note, that I have already tried this too with no luck.

<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
    </Style>
</ListView.ItemContainerStyle>
  • 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-23T16:07:33+00:00Added an answer on May 23, 2026 at 4:07 pm

    Your problem is that the ListView has an internal buildin ScrollViewer that causes the problem.

    It seems to me, that you just want the content to wrap. So ditch the ItemContainerStyle and add this to the ListView:

    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
    

    This will disable the horizontal scrollbar and makes your content wrap!

    Hope this helps!

    For completeness:

    <ListView ItemsSource="{Binding ValidationItems}"                          
                  SelectedItem="{Binding SelectedValidationItem}"                          
                  SelectionChanged="ListViewSelectionChanged" 
                  ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem getting XCode to deal with a particular file structure that
I have Thinking Sphinx setup and working however I am having a problem getting
I have the following code, however im having a problem getting window.location to work
I'm having a problem getting a bitmap to rotate properly. I have a SurfaceView
Im having a problem getting jequery autocomplete to work for rerendered textfields. I have
I am having a problem getting an old Ruby on Rails 2 app that
I'm having a problem getting my data model to work correctly. I have the
I am having a problem getting Haml to close br tags. I have tried
I am having problem getting my tooltip to work when using the jQuery load()
Having a problem getting a TreeView control to display node images. The code below

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.