The AutoCompleteBox in Silverlight is used to complete the word automatically in a text box.
Xaml page for AutoCompleteBox:
Tools to be used:
AutoCompleteBox, TextBlock :Just drag and place autocomplete box from tool box to source page.
<navigation:Page xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input" x:Class="ControlSamples.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" d:DesignWidth="640" d:DesignHeight="480" Title="Page1 Page">
<Grid x:Name="LayoutRoot">
<input:AutoCompleteBox Name="MyAutoComplete" ValueMemberBinding="{Binding Caption}" HorizontalAlignment="Left" VerticalAlignment="Top" Populating="AutoCompleteBox_Populating" MinWidth="50" MaxHeight="500" MinHeight="5" MaxWidth="500" Width="250" Height="25" IsTextCompletionEnabled="True" >
<input:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Caption}"></TextBlock>
</DataTemplate>
</input:AutoCompleteBox.ItemTemplate>
</input:AutoCompleteBox>
</Grid>
</navigation:Page>
Used Properties in AutoCompleteBox:
-
Name: Name of the control.
-
ValueMemberBinding: A field which has to be bound in an AutoCompleteBox.
-
Horizontal Alignment: Aligns the control's left position.
-
Vertical Alignment: Aligns the control's right position.
-
Width: Width of the control
-
Height: Height of the control
-
MinWidth: The control size which is not decreased below this width.
-
MinHeight: The control size which is not decreased below this height.
-
MaxWidth: The control size which is not increased above this width
-
MaxHeight: The control size which is not increased above this height.
-
IsTextCompletedEnabled: here can set text complete enable to true or false
-
Populating: is fired when typeing a letter.
C#:
void c_GetFirstpassYieldSummaryDetailsCompleted(object sender, ControlSamples.ServiceReference1.GetFirstpassYieldSummaryDetailsCompletedEventArgs e)
{
MyAutoComplete.ItemsSource = e.Result.FirstpassYieldSummaryindex;
MyAutoComplete.PopulateComplete();
}
private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e)
{
var obj= new ControlSamples.ServiceReference1.Service1Client();
obj.GetFirstpassYieldSummaryDetailsCompleted += new EventHandler<ControlSamples.ServiceReference1.GetFirstpassYieldSummaryDetailsCompletedEventArgs>(c_GetFirstpassYieldSummaryDetailsCompleted);
obj.GetFirstpassYieldSummaryDetailsAsync();
}