WrapPanel Horizontal orientation doesn't work

716 views Asked by At

With new version of kinect not exist the old kinectScrollviewer so i have used a ScrollViewer with a listView of images. The problem is the unscrollable when hidden ScrollbarVisibility or with horizontal scroll and if i use a SelectionChanged it works fine with mouse, but if i use a hand gesture after first click the selection area not disappear and so i don't select the elements I would scroll only horizontal (so i have disabled vertical), but also with your code doesn't scroll with gesture. Also the click doesn't works. If i use orientation="Vertical" it's scroll vertical (although in the example scroll horizontal using this setting), but if i use orientation="Horizontal" it doesn't works :(

 <k:KinectRegion x:Name="ChoiceExercise" Background="Black" >
            <DockPanel>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <k:KinectUserViewer Grid.Row="0" Height="100"/>
                    <ContentControl Grid.Row="1" x:Name="navigationRegion">
                        <Grid x:Name="kinectGrid">
                            <ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" k:KinectRegion.IsScrollInertiaEnabled="True">
                                <ListView Grid.Row="0" x:Name="listViewExercise" SelectionChanged="listViewExercise_SelectionChanged" BorderThickness="0" Background="Black" >
                                    <ListView.ItemsPanel>
                                        <ItemsPanelTemplate>
                                            <WrapPanel VerticalAlignment="Center" Orientation="Horizontal" />
                                        </ItemsPanelTemplate>
                                    </ListView.ItemsPanel>
                                </ListView>
                            </ScrollViewer>
                        </Grid>
                    </ContentControl>
                </Grid>
            </DockPanel>
        </k:KinectRegion>
1

There are 1 answers

5
dkozl On BEST ANSWER

ListView already contains ScrollViewer as part of default template and it's this behaviour that you need to disable by setting attached ScrollViewer.VerticalScrollBarVisibility property to Disabled

<Grid>
   <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*"/>
   </Grid.RowDefinitions>
   <k:KinectUserViewer Grid.Row="0" Height="100"/>
   <ContentControl Grid.Row="1" x:Name="navigationRegion">
      <Grid x:Name="kinectGrid">
         <ListView 
             Grid.Row="0" 
             ScrollViewer.VerticalScrollBarVisibility="Disabled" 
             x:Name="listViewExercise" 
             SelectionChanged="listViewExercise_SelectionChanged" 
             BorderThickness="0" 
             Background="Black" >
            <ListView.ItemsPanel>
               <ItemsPanelTemplate>
                  <WrapPanel VerticalAlignment="Center" Orientation="Horizontal" />
               </ItemsPanelTemplate>
            </ListView.ItemsPanel>
         </ListView>
      </Grid>
   </ContentControl>
</Grid>

Also WrapPanel with horizontal orientation is meant to stack items horizontally until item cannot fit then move to the next row. Since you you want to scroll horizontally I think horizontal StackPanel would suit you better.

<ItemsPanelTemplate>
    <StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>