ScrollViewer is not working inside groupbox?

喜夏-厌秋 提交于 2019-12-12 22:10:12

问题


Hi guys i am new to c# wpf.I have a problem that i want to include ScrollViewer in my Groupbox but it is not working my code is :

<GroupBox 
           Margin="10,10,0,0"
            Grid.Row="0"
            Grid.ColumnSpan="3"
            Height="150"           
            >
                    <ScrollViewer>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>

                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="140"/>
                    <ColumnDefinition Width="120"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>

                <Label 
                    Margin="0,6,0,0"
                    Content="SSID"
                    Grid.Row="0"
                    >      
                </Label>

                <TextBox
                      Margin="0,6,0,6"
                    Grid.Column="1">

                </TextBox>

                <Label 
                     Margin="0,6,0,0"
                    Content="(1024)"
                    Grid.Column="2"
                    >
                </Label>
                <Label 
                     Margin="0,6,0,0"
                    Content="Authentication Mode"
                    Grid.Column="0"

                    Grid.Row="1"
                    >
                </Label>
                <ComboBox 
                        Margin="0,6,0,6" 
                Grid.Row="1"
                Grid.Column="1"
                ItemsSource="{Binding ACAvailableSecurityTypes}"
                SelectedItem="{Binding ACSelectedSecurityType}"
                />
                <Label

                      Margin="0,6,0,0"
                    Grid.Row="2"
                       Grid.Column="0"
                       Content="VLAN"
                      />

                <TextBox
                      Margin="0,6,0,6"
                    Grid.Row="2"
                    Grid.Column="1"
                    />

                <Label Grid.Row="2"
                       Grid.Column="2"
                    Content="(1-4094)"/>

                <Button
                    Grid.Row="3"
                    Grid.Column="2"
                    Content="Add SSID"
                    HorizontalAlignment="Left"
                    Width="70"
                    Style="{StaticResource AppButtons}"/>
            </Grid>
                    </ScrollViewer>
                </GroupBox>

Any help would be highly appreciable.Thanks


回答1:


In Order to See your Scroll bar, your scrollviewer should have lesser height than your groupbox, do like this, you can see the scrollbar, Set the height and VerticalScrollBarVisibility

 <ScrollViewer Height="100" VerticalScrollBarVisibility="Auto">
            <GroupBox 
           Margin="10,10,0,0"
            Grid.Row="0"
            Grid.ColumnSpan="3"
            Height="150"           
            >
           ......

        </GroupBox>
 </ScrollViewer>



回答2:


Place the ScrollViewer outside the GroupBox, not inside:

<ScrollViewer>
    <GroupBox Margin="10,10,0,0"
              Grid.Row="0"
              Grid.ColumnSpan="3"
              Height="150" >

        ...
        ...

    </GroupBox>
</ScrollViewer>


来源:https://stackoverflow.com/questions/23932043/scrollviewer-is-not-working-inside-groupbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!