0

For a windows phone 10 app, I want to have a list of items show up when a user clicks on a button. I don't want to move the user to a new page, but just expand below the button to show the list. I also don't want to expand fully, but just to show a preset number of items in the list, and then users can scroll to see the other items. I have been trying this with a button, a list view and a simple storyboard on the height. The problem I am having is that I don't know how to determine what height to expand the list view to. How do I determine what the height should be to display a set of items without having to hard code a height? Is there a better way to do what I am trying to do?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Snooks
  • 91
  • 1
  • 11

1 Answers1

0

This is a common problem; XAML doesn't like to animate static values into automated ones (static '0'(be collapsed) to auto '123'(be expanded) for example).

There's two main ways to get around this.

One: Don't target the height at all, but instead target the scale property of RenderTransform. Scale is always 1(100%) and so you can say collapsed that the scale shall be 0(0%), this works quickly and easily but will cause items to take on a 'squashed' appearance as they expand/contract. See this for details

Two: More fiddly and difficult, but you have to basically bind the height/width of the container to be expanded/collapsed to the height/width of the content inside of itself, then intercept that bound value with a converter that will essentially multiply whatever the value is by 0 when IsExpanded becomes False.

To boil it down, you have to trick the height/width value into thinking it's static, whilst passing it the true automatic height of what it should display.

Community
  • 1
  • 1
Logan
  • 806
  • 8
  • 17