隐藏从代码创建的列表框ScrollBar

时间:2013-02-14 15:27:35

标签: wpf vb.net xaml

我有这个代码在我的Menu.xaml代码后面创建一个列表框(Menu.xaml.vb):

            Dim mm As New ListBox()
            AddHandler mm.SelectionChanged, AddressOf Me.ListBox_SelectionChanged

            mm.FontSize = 20
            Dim nn As New ListBoxItem
            nn.Content = "NOTIFICATIONS:"
            nn.Foreground = Brushes.White
            nn.Background = Brushes.DarkSlateBlue
            nn.FontSize = 44
            nn.FontWeight = FontWeights.Bold

            mm.Items.Add(nn)

现在我想禁用滚动,或者在其他情况下隐藏滚动条但是如果我检查mm属性则没有对滚动的引用

任何帮助或线索?

提前致谢

1 个答案:

答案 0 :(得分:3)

ScrollViewer.SetHorizontalScrollBarVisibility(mm, ScrollBarVisibility.Disabled);
ScrollViewer.SetVerticalScrollBarVisibility(mm, ScrollBarVisibility.Disabled);