在Silverlight中隐藏列表框的滚动条

Mah*_*esh 2 silverlight-4.0

请让我知道如何隐藏滚动条在Silverlight中显示.我不想要垂直或水平滚动条.我想隐藏两者.请帮忙

Chr*_*son 8

您可以将ScrollViewer.Horizo​​ntalScrollBarVisibility和/或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>
Run Code Online (Sandbox Code Playgroud)

因此,您将获得滚动条,如下所示:

[不幸的是,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>
Run Code Online (Sandbox Code Playgroud)

导致没有滚动条.

希望这可以帮助...

克里斯