Skip to content

No suggestion appear, nor list. #26

Description

@EnjMmjz

I am trying to add the AutoComplete feature to my Datagrid textbox column "Name"
My XAML code like:
<DataGridTextColumn x:Name="nameColumn" Width="100" Binding="{Binding Name}" Header="Name"> <DataGridTextColumn.EditingElementStyle> <Style TargetType="{x:Type TextBox}"> <Setter Property="behaviors:AutoCompleteBehavior.AutoCompleteItemsSource" Value="{Binding ItemsList, RelativeSource={RelativeSource AncestorType=DataGrid}}" /> <EventSetter Event="TextChanged" Handler="TextBox_TextChanged"/> </Style> </DataGridTextColumn.EditingElementStyle>
where ItemsList initialized in code as:
ObservableCollection<String> ItemsList;
and it will be updated on each textchanged event under the following handler:
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { ItemsList = new ObservableCollection<string>(); string tmp = (sender as TextBox).Text; if (tmp != "") { DataTable dt = sq.GetItemInvByName(tmp); if (dt != null) { foreach (DataRow dr in dt.Rows) { ItemsList.Add(dr["Name"].ToString()); } } } }
but when I run my code nothing happen, no suggestion shown, can anybody tell me what I miss?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions