Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I have an autocomplete box which will populate items whenever I have entered some key in that. My problem is I need to control the height of the autocomplete listitems.

My autocomplete always needs to display 15 items, if it contains more items it will need a scroll bar.

XML
<input:AutoCompleteBox Width="125" x:Name="EmployeeList" MinimumPrefixLength="1" Grid.Column="0"  HorizontalAlignment="Stretch" FilterMode="Contains"  Margin="2>
         <input:AutoCompleteBox.ItemTemplate>
             <DataTemplate >
                 <highlight:HighlightingTextBlock HighlightText="{Binding SearchText, ElementName=Employee}"  Text="{Binding}"/>
             </DataTemplate>
         </input:AutoCompleteBox.ItemTemplate>
     </input:AutoCompleteBox>
Posted
Updated 13-Mar-11 23:56pm
v2
Comments
LittleYellowBird 14-Mar-11 5:57am    
Hi, it is not clear what your question is. What part of this is not working? What bit are you having difficulties with? If you can explain better you will get a faster response. Just a suggestion. :)
Sandeep Mewara 14-Mar-11 6:26am    
Comment from OP:
thanks Alison, The AutoCompletbox always need to display 15 records even it contains moreitems For example if i am entering "e" ,My autocomplete box is displaying matching records in my case lets say 20 records ,but i need the autocomplete box need to display only 15 recods, if records size is >10 scroll viewer need to come
LittleYellowBird 14-Mar-11 7:04am    
Hi, I am sorry but I can't help you as I know nothing about Silverlight, I just thought your question was a bit vague. Perhaps others who are more knowledgable will be able to assist. I do wonder how it would know which 15 out of 20 (in your example) you want it to display? Best of Luck, Ali :)
Gopinath Sugumar 14-Mar-11 7:16am    
thanks Alison,
Me got the solution we need to add one property MaxDropDownHeight="220" to the autocomplete box so that we can control the height of the Autocomplete itemlist

<input:AutoCompleteBox MaxDropDownHeight="220" Width="125" x:Name="EmployeeList" MinimumPrefixLength="1" Grid.Column="0" HorizontalAlignment="Stretch" FilterMode="Contains" Margin="2>
<input:AutoCompleteBox.ItemTemplate>
<datatemplate>
<highlight:highlightingtextblock highlighttext="{Binding SearchText, ElementName=Employee}" text="{Binding}" xmlns:highlight="#unknown">

</input:AutoCompleteBox.ItemTemplate>
</input:AutoCompleteBox>

Hi,

You can do that by adding this code into style-sheet:
CSS
ul {
height:170px;//you need to change the height value as much items you want
overflow:auto;
}


-----
Regards,
Pavanraje Dongare
(Unique way towards Right Solution)
 
Share this answer
 
Me got the solution we need to add one property MaxDropDownHeight="220" to the autocomplete box so that we can control the height of the Autocomplete itemlist



XML
<input:AutoCompleteBox MaxDropDownHeight="220" Width="125" x:Name="EmployeeList" MinimumPrefixLength="1"
                           Grid.Column="0" HorizontalAlignment="Stretch" FilterMode="Contains" Margin="2>
                           <input:AutoCompleteBox.ItemTemplate>
//ur template
                           </input:AutoCompleteBox.ItemTemplate>
    </input:AutoCompleteBox>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900