FetFrumos
FetFrumos

Reputation: 5944

ItemsWrapGrid and item stretch (uwp)

I created univeral windows app. I use GridView with ItemsWrapGrid. I need to stretch item by horizontal.

It is my test code:

<GridView x:Name="Test"
          AutomationProperties.AutomationId="ItemGridView"
          AutomationProperties.Name="Items In Group"
          IsItemClickEnabled="True"
          IsSwipeEnabled="False"
          ScrollViewer.VerticalScrollBarVisibility="Hidden"
          ScrollViewer.VerticalScrollMode="Disabled"
          SelectionMode="Single">

    <GridView.ItemContainerStyle>
        <Style TargetType="GridViewItem">
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Stretch" />
        </Style>
    </GridView.ItemContainerStyle>


    <GridView.ItemTemplate>
        <DataTemplate>

            <TextBlock MinWidth="100"
                       HorizontalAlignment="Stretch"
                       VerticalAlignment="Stretch"
                       Text="{Binding}"
                       TextWrapping="WrapWholeWords" />


        </DataTemplate>
    </GridView.ItemTemplate>

    <GridView.Transitions>
        <TransitionCollection>
            <EntranceThemeTransition />
        </TransitionCollection>
    </GridView.Transitions>
    <GridView.ItemsPanel>
        <ItemsPanelTemplate>
            <ItemsWrapGrid Orientation="Vertical" />
        </ItemsPanelTemplate>
    </GridView.ItemsPanel>
</GridView>

it is my code behinded:

        this.InitializeComponent();
        var items = new List<string>
        {
            "test",
            "test test",
            "test test 000 1111 test test 000 1111",
        };
        Test.ItemsSource = items;

it is my result:

enter image description here

the text of the last line is not all. How do I display the full text?

Upvotes: 1

Views: 1405

Answers (1)

Justin Lam
Justin Lam

Reputation: 799

Try using ItemsStackPanel instead of ItemsWrapGrid.

<GridView.ItemsPanel>
     <ItemsPanelTemplate>
          <ItemsStackPanel Orientation="Vertical" />
     </ItemsPanelTemplate>
</GridView.ItemsPanel>

Upvotes: 2

Related Questions