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);

}
}
}

最新文章

  1. 获取文件Md5值
  2. 解决phalcon读取mysql乱码
  3. SQL Server 2008通过LinkServer操作ORACLE
  4. Swiper教程 —— 使用方法
  5. Runas命令:能让域用户/普通User用户以管理员身份运行指定程序。
  6. Bootstrap系列 -- 17. 复选框checkbox和单选择按钮radio
  7. arcgis 栅格计算器(Spatial Analyst/Raster Calculator)
  8. EntityFramework.Extended扩展用法
  9. crontab定时运行git命令 更新代码库
  10. Delphi 动态改变Rzsplitter的Orientation(方向)属性
  11. HTML5画布(阴影)
  12. [置顶] P2P之我见,关于打洞的学问-------开篇
  13. AOJ/搜索递归分治法习题集
  14. Linux通过shell执行自动化部署
  15. 在CentOS下安装Git
  16. Windows10文件目录下添加 Shift+右键打开管理员Powershell窗口
  17. Python实现简单的HttpServer
  18. 配置 SQL Server 2008 Email 发送以及 Job 的 Notification通知功能
  19. FORM中使用onSubmit=&quot;return false&quot;防止表单自动提交,以及submit和button提交表单的区别
  20. WebService(JAX-WS、XFire、Axis三种)获取客户端ip

热门文章

  1. python基础(30):黏包、socket的其他方法
  2. 怎样深入学习php,成为php高手!?
  3. java核心技术第六篇之断言、日志、包装类型和工具类
  4. PHP setcookie 网络函数
  5. 微信小程序和支付宝小程序富文本使用
  6. RSA 非对称加密算法的Java实现
  7. [20190929]bash使用bc计算的相关问题.txt
  8. HIVE SQL产生的文件数量及参数调优
  9. 4-8 pie与布局
  10. golang数据结构和算法之CircularBuffer环形缓冲队列