开发者

controlling vertical scroll bar in silverlight autocompletebox

I have a Silverlight application that 开发者_JAVA百科uses the AutoCompleteBox. This AutoCompleteBox is defined as follows:

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

I want the vertical scroll bar in the drop down list to always be visible. This way I can size my item template appropriately. My question is, How do I always display the vertical scroll bar in the drop down box of an autocompletebox?

Thank you!


You'll need to set the VerticalScrollbarVisibility on the containing ScrollViewer. You may be able to accomplish this by creating an Implicit Style within the AutoCompleteBox Style, as shown below. Otherwise you'll need to create a Style for the AutoCompleteBox and set the Property or Style on the ScrollViewer directly.

<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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜