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>
精彩评论