效果如图
![](https://img-my.csdn.net/uploads/201301/11/1357893862_9201.jpg)
源码下载地址:http://download.csdn.net/detail/feitian19873000/4985603
xaml文件内容:
<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:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
x:Class="SilverlightApplication1.MainPage"
d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot">
<telerikInput:RadComboBox x:Name="combo" Text="{Binding Text, Mode=TwoWay}"
IsEditable="True" Height="25" Width="200">
<telerikInput:RadComboBox.Items>
<telerikInput:RadComboBoxItem>
<telerikInput:RadComboBoxItem.Template>
<ControlTemplate>
<telerikGrid:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False" ShowGroupPanel="False" CanUserFreezeColumns="False"
RowIndicatorVisibility="Collapsed" IsReadOnly="True"
IsFilteringAllowed="False" ItemsSource="{Binding Items}"
Width="200" Height="150" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
<telerikGrid:RadGridView.Columns>
<telerikGrid:GridViewDataColumn Header="编号" DataMemberBinding="{Binding ID}"/>
<telerikGrid:GridViewDataColumn Header="名称" DataMemberBinding="{Binding Name}"/>
</telerikGrid:RadGridView.Columns>
</telerikGrid:RadGridView>
</ControlTemplate>
</telerikInput:RadComboBoxItem.Template>
</telerikInput:RadComboBoxItem>
</telerikInput:RadComboBox.Items>
</telerikInput:RadComboBox>
</Grid>
</UserControl>
xaml.cs文件内容:
using System.Windows.Controls;
namespace SilverlightApplication1
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
DataContext = new MyDataContext(this.combo);
}
}
}
MyDataContext类的内容
using System;
using System.Linq;
using System.ComponentModel;
using Telerik.Windows.Data;
using Telerik.Windows.Controls;
namespace SilverlightApplication1
{
public class MyDataContext : INotifyPropertyChanged
{
private RadComboBox combo;
public MyDataContext(RadComboBox combobox)
{
this.combo = combobox;
}
QueryableCollectionView _Items;
public QueryableCollectionView Items
{
get
{
if (_Items == null)
{
_Items = new QueryableCollectionView(from i in Enumerable.Range(0, 10000)
select new MyObject() { ID = i, Name = String.Format("Name{0}", i) });
_Items.FilterDescriptors.Add(new FilterDescriptor("Name", FilterOperator.Contains, _Text != null? _Text : ""));
}
return _Items;
}
}
string _Text;
public string Text
{
get
{
return _Text;
}
set
{
if (_Text != value)
{
_Text = value;
if (_Items != null)
{
((FilterDescriptor)_Items.FilterDescriptors[0]).Value = _Text;
}
OnPropertyChanged("Text");
}
}
}
MyObject _SelectedItem;
public MyObject SelectedItem
{
get
{
return _SelectedItem;
}
set
{
if (_SelectedItem != value)
{
_SelectedItem = value;
_Text = _SelectedItem.Name;
OnPropertyChanged("Text");
OnPropertyChanged("SelectedItem");
}
}
}
#region INotifyPropertyChanged Members
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
this.combo.IsDropDownOpen = false;
}
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
public class MyObject
{
public int ID { get; set; }
public string Name { get; set; }
}
}
参考链接: http://blogs.telerik.com/vladimirenchev/posts/10-04-09/how-to-filter-as-you-type-radgridview-inside-radcombobox-for-wpf-and-silverlight.aspx