0

I have a listview that can contain anywhere between 1 & 10 items of text. The ListView must be contained in a specific size of a grid.

I want each item be able to wrap onto another row (Which I can get working ok) but when the items eventually reach the bottom of the Grid region, I then want the items to resize in font, maintaining the wrapped text & not allowing an scrolling.

I may be asking too much of WPF or not explaining this very well.

    <ListView Name="lvWrap" ItemsSource="{Binding Directions}" Style="{DynamicResource ListViewStyle1}" FontSize="29">
        <ListView.ItemTemplate>
            <DataTemplate>
                <DockPanel Name="MainGrid" HorizontalAlignment="Stretch">
                    <TextBlock Text="{Binding}" TextWrapping="Wrap"/>
                </DockPanel>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

This wraps every item ok, but the bottom items dissapear off screen. I dont want this to happen

Neil Hobson
  • 515
  • 1
  • 7
  • 14

1 Answers1

0

You're not asking too much... just about anything is possible with WPF. However, you are asking a lot and most likely, too much for users here. The only way that I could imagine that you could achieve your requirement is for you to implement a custom Panel and set it as the ListView.ItemsPanel.

Inside a Panel, or more specifically, the ArrangeOverride method of the Panel is one of the few places where you could detect that the items have reached the bottom of the available space. While creating a custom Panel is not too difficult, it is also no menial task. If you choose to do this, you can take a look at one of the following links in order to get a better understanding of how this is done:

How to create a Custom Layout Panel in WPF

Creating Custom Panels In WPF

Sheridan
  • 68,826
  • 24
  • 143
  • 183