Not Defteri

Akılda duracagına burda dursun

Microsoft Silverlight ile AutoComplete TextBox

Silverlight 3 ile gelen autocomplatetextbox kontrolunun kullanımını için aşağıdaki gibi bir silverlight Application projesi oluşturalım.

Silverlight projesinin references kısmına sağ tuşla basarak Add References' ı tıklayıp açılan ekrandan System.windows.controls.input dll'ini ekleyin.

 

Daha sonra mainpage.xaml de şu satırları ekleyin.

<UserControl

    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:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input" x:Class="AutoCompleteTextBox.MainPage"
    d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
      <Grid.ColumnDefinitions>
          <ColumnDefinition Width="0.234*"/>
          <ColumnDefinition Width="0.766*"/>
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
          <RowDefinition Height="0.077*"/>
          <RowDefinition Height="0.923*"/>
      </Grid.RowDefinitions>
      <TextBlock Margin="0,9,8,8" Text="BAGLI OLDUGUNUZ İL" TextWrapping="Wrap"/>
      <input:AutoCompleteBox x:Name="Textbox1" Margin="8,8,0,9" HorizontalAlignment="Left" Width="166" Grid.Column="1"/>
  </Grid>
</UserControl>
 
MainPage.xaml.cs de
 
namespace AutoCompleteTextBox
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            List<string> iller = new List<string>();
            iller.Add("Adana");
            iller.Add("Adiyaman");
            iller.Add("Ardahan");
            iller.Add("istanbul");
            iller.Add("izmir");
            iller.Add("Ankara");
            iller.Add("Kocaeli");
            Textbox1.ItemsSource = iller;              
        }
    }
}
Uygulamayı çalıştırdıgınızda;
 

 

 

 

 

örnek kodu indirin:

AutoCompleteTextBox.zip (669,75 kb)

Posted: Aug 07 2009, 02:12 by kkaradag | Comments (0) RSS comment feed |
  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Silverlight3