Hi,
I'm trying to mimic the autocomplete behavior of Excel in a GridView. For this, I have DataBoundColumns, and replaced the CellEditTemplate with an AutoCompleteBox (ACB).
The not-so-simple ACB ItemsSource binding is for an MVVM approach, trying to reach the VM for the GridView.
My questions:
I'm trying to mimic the autocomplete behavior of Excel in a GridView. For this, I have DataBoundColumns, and replaced the CellEditTemplate with an AutoCompleteBox (ACB).
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding ItemContent}"
>
<
telerik:GridViewDataColumn.CellEditTemplate
>
<
DataTemplate
>
<
telerik:RadAutoCompleteBox
ItemsSource
=
"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=telerik:RadGridView, AncestorLevel=1}, Path=DataContext.ListOfItemContent}"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellEditTemplate
>
</
telerik:GridViewDataColumn
>
The not-so-simple ACB ItemsSource binding is for an MVVM approach, trying to reach the VM for the GridView.
My questions:
- Is there an easier way to do this? (for example, the ComboBoxColumn has ItemsSource and ItemsSourceBinding)
- What is the "Text" property for an ACB? (Can't find one, and the on-line documentation is a bit scarce for this control...)
- Could you make a new GridColumn type, that would use /inherit from/ ACB? (like the special ones you already have)
According to this thread, the Text property would be the SearchText property, and it has some issues:
http://www.telerik.com/community/forums/wpf/autocompletebox/setting-the-searchtext.aspx
I can reproduce the same exception with the above code. The ListOfItemContent is the list of strings in the current column. It's in the VM.
public IEnumerable<
string
> ListOfItemContent
{
get
{
return
(from i in this.MyBusinessObjects
select i.ItemContent).Distinct();
}
}
Thank you,
Gyula