Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Unable to stretched ListBoxItem and a DataRowItem #178

Open
MikeAlhayek opened this issue Mar 18, 2018 · 0 comments
Open

Unable to stretched ListBoxItem and a DataRowItem #178

MikeAlhayek opened this issue Mar 18, 2018 · 0 comments

Comments

@MikeAlhayek
Copy link

MikeAlhayek commented Mar 18, 2018

I am trying to write a WPF application using c#.

I have a view where I need to show a label in one column and a text box in a second column in a ListBox For some reason I can't seems to stretch the items. As you can see, I am using HorizontalContentAlignment="Stretch" which many hits out there suggest to do. I even tried adding ScrollViewer.HorizontalScrollBarVisibility="Disabled" to the ListBox with no luck.

Here is the XAML code of my view

    <ListBox HorizontalContentAlignment="Stretch"
             ItemsSource="{Binding GroupItems }">
    <ListBox.ItemTemplate>
        <DataTemplate>

                <Grid HorizontalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="2*" />
                    </Grid.ColumnDefinitions>

                    <Label Content="{Binding Path=Title}"
                           Grid.Column="0"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Right"
                           Padding="0 0 7 0"
                           Margin="0,6,0,3" />

                    <TextBox Grid.Column="1"
                             Text="{Binding Path=Amount, Mode=TwoWay}"
                             HorizontalAlignment="Stretch" />
                </Grid>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
Here is a screenshot of how it looks like.

screenshot_5

screenshot_6

Here is how the same code look without this package
screenshot_7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant