0

Im writing UWP app using Xaml I try to put list view where I have list of attandence but I cant see the scroll ba. I have also scrollView on all the page for case that the user minimize the page so if I have a long attandnece in my list I can scroll down all the page to see the items in the buttom of the attendence but I would like to scroll only inside the list view and not all the page. i try many diffrenet things nut nothing works this is my Xaml code:

<Grid Width="600" Visibility="{Binding EventVisible}"  ScrollViewer.HorizontalScrollMode="Auto">
    <StackPanel>
        <ListView VerticalAlignment="Top"  x:Name="GuestsList" ItemsSource="{Binding Guests, Mode=TwoWay}" >
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Border BorderBrush="{StaticResource SystemControlBackgroundBaseLowBrush}" BorderThickness="0,0,0,2">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBox Text="{Binding CustomId, Mode=TwoWay}" Grid.Row="0" Grid.Column="0"/>
                            <Button  Command="{Binding ElementName=GuestsList, Path=DataContext.UpdateGuestCommand}" CommandParameter="{Binding}" Grid.Row="0" Grid.Column="1" >
                                <SymbolIcon Symbol="Edit"></SymbolIcon>
                            </Button>
                            <Button Command="{Binding ElementName=GuestsList, Path=DataContext.RemoveGuestCommand}" CommandParameter="{Binding}"  Grid.Row="0" Grid.Column="2">
                                <SymbolIcon Symbol="Delete"></SymbolIcon>
                            </Button>

                        </Grid>
                    </Border>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackPanel>
</Grid>
Vijay Nirmal
  • 5,239
  • 4
  • 26
  • 59
orel
  • 93
  • 1
  • 6

2 Answers2

0

Your DataTemplate item is a Border with a Grid inside. Neither of those controls will provide a ScrollViewer so you wouldn't be able to scroll within a ListView item. Try something like this:

<Grid Width="600" Visibility="{Binding EventVisible}"  ScrollViewer.HorizontalScrollMode="Auto">
    <StackPanel>
        <ListView VerticalAlignment="Top"  x:Name="GuestsList" ItemsSource="{Binding Guests, Mode=TwoWay}" >
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Border BorderBrush="{StaticResource SystemControlBackgroundBaseLowBrush}" BorderThickness="0,0,0,2">
                        <GridView>
                            <Grid Name="FirstRow">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <TextBox Text="{Binding CustomId, Mode=TwoWay}" Grid.Column="0"/>
                                <Button  Command="{Binding ElementName=GuestsList, Path=DataContext.UpdateGuestCommand}" CommandParameter="{Binding}" Grid.Column="1" >
                                    <SymbolIcon Symbol="Edit"></SymbolIcon>
                                </Button>
                                <Button Command="{Binding ElementName=GuestsList, Path=DataContext.RemoveGuestCommand}" CommandParameter="{Binding}"  Grid.Column="2">
                                    <SymbolIcon Symbol="Delete"></SymbolIcon>
                                </Button>
                            </Grid>
                        </GridView>
                    </Border>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackPanel>
</Grid>
Sean O'Neil
  • 1,222
  • 12
  • 22
  • Hi, Thanks for your answer! I try this but get the same result. I still dont have scroll in my scroll view :( – orel Nov 25 '17 at 07:28
  • 1
    @orel If you set your ListView with an solid Height and the Height is not enough to display your items, then you will be able to see scrollviewer in your ListView itself. The auto scrollmode is described as " Scrolling is enabled but behavior uses a "rails" manipulation mode." – Barry Wang Nov 28 '17 at 05:39
0

I was able to circumvent the scroll behavior by attaching behaviors.

see https://stackoverflow.com/a/7003338/7025289 for more detailed info.

xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:behaviors="clr-namespace:TestProject.Management.Behaviors"

<ListView ItemsSource="{Binding Path=SomeData}">
    <b:Interaction.Behaviors>
        <behaviors:IgnoreMouseWheelBehavior />
    </b:Interaction.Behaviors>
</ListView>
chrisroker0
  • 140
  • 2
  • 7