windowsalignmentuwpstretchflipview

UWP: How to wrap content in a FlipView?


In an UWP-App I'm developing I make use of a FlipView.

My problem is, that I'd like the FlipView (more precise: its FlipViewItems) to wrap their content. For example: a FlipViewItem with a StackPanel as its content should have the dimensions of that said child. (like 'wrap_content' in Android)

Unlike wanted, the FlipView and its items keep stretching over the complete screen. I'm already adjusting things like the alignments in a custom style, but at the moment I'm only successful with changing the width/height hardcoded.

Is there a way to bind the width/height of a FlipViewItem to its child? For example the behaviour of a StackPanel is perfect: it just adapts it size to the child's size.


Solution

  • I found a solution myself:

    I'm binding the dimensions of my FlipView to the ActualWidth/ActualHeight-Property of the currently selected item

    Height="{Binding Path=SelectedItem.ActualHeight, ElementName=MyFlipView}"
    Width="{Binding Path=SelectedItem.ActualWidth, ElementName=MyFlipView}"