码迷,mamicode.com
首页 > Windows程序 > 详细

WPF toolkit AutoCompleteBox

时间:2016-12-28 18:44:40      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:nav   generic   null   complete   str   data   tac   put   assembly   

checked http://www.broculos.net/2014/04/wpf-autocompletebox-autocomplete-text.html#.WGNnq4N95aQ.

1.Search Wpf toolkit in Nuget and install;

 View:

<Window x:Class="WpfApplication28.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
Title="MainWindow" Height="350" Width="525">
<Grid>
<controls:AutoCompleteBox ItemsSource="{Binding Names}" Height="120" BorderBrush="Black" BorderThickness="5" FontSize="50"/>
</Grid>
</Window>

 

xaml.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication28
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.DataContext = new ACBViewModel();
}

}


}

 

VM:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace WpfApplication28
{
class ACBViewModel:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if(PropertyChanged!=null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}

private ObservableCollection<string> names;
public ObservableCollection<string> Names
{
get
{
return names;
}
set
{
names = value;
OnPropertyChanged("Names");
}
}

public ACBViewModel()
{
List<string> namesList = new List<string>();
namesList.Add("ST");
namesList.Add("ZTT");
namesList.Add("LY");
namesList.Add("WYQ");
namesList.Add("ZCQ");
namesList.Add("HT");
Names = new ObservableCollection<string>(namesList);

}
}
}

 

WPF toolkit AutoCompleteBox

标签:nav   generic   null   complete   str   data   tac   put   assembly   

原文地址:http://www.cnblogs.com/Fred1987/p/6229660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!