0

I am having a problem that I want to include an ScrollViewer in my wpf application I used ScrollViewer property but it is just showing ScrollBar on the right side but it do not allow me to move.

My view gets down the Window but I do not able to see that. My code is:

<ScrollViewer >
        <StackPanel Orientation="Vertical" ScrollViewer.CanContentScroll="True">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="170"/>
                <ColumnDefinition Width="200"/>
                <ColumnDefinition Width="65"/>
                <!--<ColumnDefinition Width="205"/>-->

            </Grid.ColumnDefinitions>

            <Label
              Grid.Row="0"
              Grid.ColumnSpan="1"
              HorizontalAlignment="Left"
              Content="IP Configuration:"
              Foreground="Black"
              FontWeight="ExtraBold"
              FontSize="14"
              Opacity="0.8"  
            />

            <Label
             Grid.Row="1"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="Wireless IP Address"
             Foreground="Black"
             Opacity="0.8"  
             />

            <TextBox
            Grid.Row="1"
            Grid.Column="1"
            VerticalAlignment="Center"
           />

            <Label
             Grid.Row="2"
             Grid.ColumnSpan="1"
             HorizontalAlignment="Left"
             Content="AP Group Configuration"
             Foreground="Black"
             FontWeight="ExtraBold"
            FontSize="14"
             Opacity="0.8"  
             />
            <Label
             Grid.Row="3"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="Group ID"
             Foreground="Black"
             Opacity="0.8"  
             Margin="0,0,0,5"
             />

            <TextBox
            Grid.Row="3"
            Grid.Column="1"
            VerticalAlignment="Center"
            Margin="0,0,0,5"
           />

            <Label
             Grid.Row="3"
             Grid.Column="2"
             VerticalAlignment="Center"
             Content="(1-1024)"
             Foreground="Black"
             Opacity="0.8"  
             Margin="0,0,0,5"
             />

            <Label
             Grid.Row="4"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="AP Hardware Type"
             Foreground="Black"
             Opacity="0.8"  
             />

            <ComboBox
            Grid.Row="4"
            Grid.Column="1"
            >
                <ComboBoxItem >0-Any</ComboBoxItem>
                <ComboBoxItem>21-ARC1000MAP , Indoor Radio b/g/n</ComboBoxItem>
                <ComboBoxItem>22-ARC2000MAP , Dual Radio a/n, b/g/n</ComboBoxItem>
            </ComboBox>

            <Button
            Grid.Row="4"
            Grid.Column="2"
            Margin="10,0,0,0"
            Style="{StaticResource AppButtons}">
                Add
            </Button>

            <TextBox 
            Grid.Row="5"
            Grid.ColumnSpan="3"
            IsReadOnly="True"
            IsEnabled="False"
            Visibility="Hidden"
            Height="10"/>

            <DataGrid Grid.Row="6"
                  Grid.ColumnSpan="3"
                  AutoGenerateColumns="False">
                <DataGrid.Columns>
                    <DataGridTextColumn Width="100"  Header="Group ID" />
                    <DataGridTextColumn Header="AP Hardware Type"/>
                </DataGrid.Columns>
            </DataGrid>

            <Label
             Grid.Row="7"
             Grid.Column="0"
             HorizontalAlignment="Left"
             Content="Network Configuration"
             FontWeight="ExtraBold"
             Foreground="Black"
            FontSize="14"
             Opacity="0.8"  
             />

            <Label
             Grid.Row="8"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="SSID"
             Foreground="Black"
             Opacity="0.8"  
             />

            <TextBox
            Grid.Row="8"
            Grid.Column="1"
            VerticalAlignment="Center"
            Text="Guest Network"
           />

            <Label
             Grid.Row="9"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="Security"
             Foreground="Black"
             Opacity="0.8"  
             />

            <ComboBox 
                Grid.Row="9"
                Grid.Column="1"
                ItemsSource="{Binding ACAvailableSecurityTypes}"
                SelectedItem="{Binding ACSelectedSecurityType}"
                >

            </ComboBox>

            <view:ACSecurityStaticWEP
                Grid.Row="10"
                Grid.ColumnSpan="2"
                HorizontalAlignment="Left" 
                VerticalAlignment="Top"
                Visibility="{Binding IsACStaticWep, Converter={StaticResource BooleanToVisibilityConverter}}"/>

        </Grid>
        </StackPanel>
    </ScrollViewer>
10
  • What is the parent of ScrollViewer? Commented May 26, 2014 at 12:26
  • All the controls are inside ScrollViewer ,ScrollViewer itself behaving as parent control! Commented May 26, 2014 at 12:40
  • So ScrollViewer is placed directly in the Window? Commented May 26, 2014 at 12:41
  • Yes it worked i packed my ScrollViewer inside another Grid and ScrollBar starts moving now ...thanks Commented May 26, 2014 at 12:48
  • @CodeSniper Dint my solution work? Commented May 26, 2014 at 13:08

2 Answers 2

1

Your ScrollViewer height is infinite, set it to any value and that should do it

Sign up to request clarification or add additional context in comments.

1 Comment

Can you give an example i tried but it did not work!
0

You need to set VerticalScrollBarVisibility of ScrollViewer

<ScrollViewer VerticalScrollBarVisibility="Auto >

Also your StackPanel Height property Should have some value

<StackPanel Height="500" Width="376"  Orientation="Vertical"  >

Complete Code:

<ScrollViewer VerticalScrollBarVisibility="Auto" >
            <StackPanel Height="700" Orientation="Vertical" ScrollViewer.CanContentScroll="True">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="170"/>
                        <ColumnDefinition Width="200"/>
                        <ColumnDefinition Width="65"/>
                        <!--<ColumnDefinition Width="205"/>-->

                    </Grid.ColumnDefinitions>

                    <Label
              Grid.Row="0"
              Grid.ColumnSpan="1"
              HorizontalAlignment="Left"
              Content="IP Configuration:"
              Foreground="Black"
              FontWeight="ExtraBold"
              FontSize="14"
              Opacity="0.8"  
            />

                    <Label
             Grid.Row="1"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="Wireless IP Address"
             Foreground="Black"
             Opacity="0.8"  
             />

                    <TextBox
            Grid.Row="1"
            Grid.Column="1"
            VerticalAlignment="Center"
           />

                    <Label
             Grid.Row="2"
             Grid.ColumnSpan="1"
             HorizontalAlignment="Left"
             Content="AP Group Configuration"
             Foreground="Black"
             FontWeight="ExtraBold"
            FontSize="14"
             Opacity="0.8"  
             />
                    <Label
             Grid.Row="3"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="Group ID"
             Foreground="Black"
             Opacity="0.8"  
             Margin="0,0,0,5"
             />

                    <TextBox
            Grid.Row="3"
            Grid.Column="1"
            VerticalAlignment="Center"
            Margin="0,0,0,5"
           />

                    <Label
             Grid.Row="3"
             Grid.Column="2"
             VerticalAlignment="Center"
             Content="(1-1024)"
             Foreground="Black"
             Opacity="0.8"  
             Margin="0,0,0,5"
             />

                    <Label
             Grid.Row="4"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="AP Hardware Type"
             Foreground="Black"
             Opacity="0.8"  
             />

                    <ComboBox
            Grid.Row="4"
            Grid.Column="1"
            >
                        <ComboBoxItem >0-Any</ComboBoxItem>
                        <ComboBoxItem>21-ARC1000MAP , Indoor Radio b/g/n</ComboBoxItem>
                        <ComboBoxItem>22-ARC2000MAP , Dual Radio a/n, b/g/n</ComboBoxItem>
                    </ComboBox>

                    <Button
            Grid.Row="4"
            Grid.Column="2"
            Margin="10,0,0,0">


                    </Button>

                    <TextBox 
            Grid.Row="5"
            Grid.ColumnSpan="3"
            IsReadOnly="True"
            IsEnabled="False"
            Visibility="Hidden"
            Height="10"/>

                    <DataGrid Grid.Row="6"
                  Grid.ColumnSpan="3"
                  AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="100"  Header="Group ID" />
                            <DataGridTextColumn Header="AP Hardware Type"/>
                        </DataGrid.Columns>
                    </DataGrid>

                    <Label
             Grid.Row="7"
             Grid.Column="0"
             HorizontalAlignment="Left"
             Content="Network Configuration"
             FontWeight="ExtraBold"
             Foreground="Black"
            FontSize="14"
             Opacity="0.8"  
             />

                    <Label
             Grid.Row="8"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="SSID"
             Foreground="Black"
             Opacity="0.8"  
             />

                    <TextBox
            Grid.Row="8"
            Grid.Column="1"
            VerticalAlignment="Center"
            Text="Guest Network"
           />

                    <Label
             Grid.Row="9"
             Grid.Column="0"
             VerticalAlignment="Center"
             Content="Security"
             Foreground="Black"
             Opacity="0.8"  
             />

                    <ComboBox 
                Grid.Row="9"
                Grid.Column="1"
                ItemsSource="{Binding ACAvailableSecurityTypes}"
                SelectedItem="{Binding ACSelectedSecurityType}"
                >

                    </ComboBox>


                </Grid>
            </StackPanel>
        </ScrollViewer>

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.