0

我有一个使用 AutoCompleteBox 的 Silverlight 应用程序。这个 AutoCompleteBox 定义如下:

  <sdk:AutoCompleteBox x:Name="myAutoCompleteBox" HorizontalAlignment="Stretch" 
    MaxHeight="240" MaxDropDownHeight="240" IsTextCompletionEnabled="False"    
    MinimumPrefixLength="4" MinimumPopulateDelay="100"                 
    ItemsSource="{Binding MyElements}" ItemTemplate="{StaticResource itemTemplate}" />

我希望下拉列表中的垂直滚动条始终可见。这样我可以适当地调整我的项目模板的大小。我的问题是,如何始终在自动完成框的下拉框中显示垂直滚动条?

谢谢!

4

1 回答 1

0

您需要VerticalScrollbarVisibility在包含的ScrollViewer. 您可以通过在 中创建隐式来完成此Style操作AutoCompleteBox Style,如下所示。否则,您将需要创建一个 StyleAutoCompleteBox并直接设置 Property 或Styleon ScrollViewer

<sdk:AutoCompleteBox x:Name="myAutoCompleteBox" HorizontalAlignment="Stretch" 
    MaxHeight="240" MaxDropDownHeight="240" IsTextCompletionEnabled="False"    
    MinimumPrefixLength="4" MinimumPopulateDelay="100"                 
    ItemsSource="{Binding MyElements}" ItemTemplate="{StaticResource itemTemplate}">
    <sdk:AutoCompleteBox.Resources>
        <Style TargetType="ScrollViewer">
            <Setter Property="VerticalScrollBarVisibility" Value="Visible"/>
        </Style>
     </sdk:AutoCompleteBox.Resources>
</sdk:AutoCompleteBox>
于 2011-03-23T14:22:24.137 回答