请告诉我如何隐藏滚动条以免在Silverlight中显示。 我不想要垂直或水平滚动条。我想隐藏两者。请帮忙
答案 0 :(得分:8)
您可以将ScrollViewer.HorizontalScrollBarVisibility和/或ScrollViewer.VerticalScrollBarVisibility附加属性设置为“已禁用”。例如,如果您有以下XAML:
<ListBox Height="100" Name="listBox1" Width="100">
<ListBoxItem>
<Rectangle Width="200" Height="50" Fill="#FF894220" />
</ListBoxItem>
<ListBoxItem>
<Rectangle Width="200" Height="50" Fill="#FFB94222" />
</ListBoxItem>
</ListBox>
因此您将获得滚动条,如下所示:
[不幸的是,StackOverflow不会让我发布图片,直到我获得更高的声誉(我正在努力建立)。你必须想象它或亲自尝试]
将ScrollViewer附加属性添加到ListBox元素:
<ListBox Height="100" Name="listBox1" Width="100"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBoxItem>
<Rectangle Width="200" Height="50" Fill="#FF894220" />
</ListBoxItem>
<ListBoxItem>
<Rectangle Width="200" Height="50" Fill="#FFB94222" />
</ListBoxItem>
</ListBox>
导致没有滚动条。
希望这会有所帮助......
克里斯