首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

WPF,这个滚动条为何不出现呢

2013-08-04 
WPF,这个滚动条为什么不出现呢?Window x:ClassWPF熊俊.MainWindow xmlnshttp://schemas.microsoft.c

WPF,这个滚动条为什么不出现呢?


<Window x:Class="WPF熊俊.MainWindow"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="376" Width="595" >
    <Grid Height="288" Name="grid1" Width="486" >
        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <Button Content="button2" Height="223" HorizontalAlignment="Left" Margin="211,16,0,0" Name="button2" VerticalAlignment="Top" Width="75" />
        </ScrollViewer>
    </Grid>
</Window>


上面的代码,当缩小窗口的时候,为什么没有出现滚动条呢?
[解决办法]
你设为Auto后ScrollViewer内的Content没有超过ScrollViewer的宽或高,所以不会出现
[解决办法]
你的滚动条是在Grid内部的,而Grid的宽高被你写死了,不会因为窗口的大小改变而改变,最多被剪裁。对于Grid内部的元素来说,它并没有超出Grid的大小,因此不需要滚动条。

热点排行