Я новичок в WPF. У меня есть AutoCompleteBox. Когда я ввожу текст поиска, выпадающий список заполняется. Он содержит элементы. Я могу выбрать эти элементы и сохранить их в базе данных с помощью стрелки вниз или вверх.Вот мой код
<AutoComplete:AutoCompleteBox Background="White" Tag="TagName..." Margin="0,0,28.8,0" Name="txtCustomTagName" BorderBrush="#FF104E8B" FontWeight="Normal" BorderThickness="1,1,0,1" FontSize="14" Foreground="#FF104E8B" TextChanged="txtCustomTagName_TextChanged" LostFocus="txtCustomTagName_LostFocus" PreviewTextInput="txtCustomTagName_PreviewTextInput" Populating="txtCustomTagName_Populating" >
<AutoComplete:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<TextBlock />
</DataTemplate>
</AutoComplete:AutoCompleteBox.ItemTemplate>
</AutoComplete:AutoCompleteBox>
//Populated Event:-
private void txtCustomTagName_Populating(object sender, PopulatingEventArgs e)
{
string strFilePath = "";
string strNewFile = "";
strFilePath += @"../../FIXDictionaries/";
string typedString = txtCustomTagName.Text; ;
strNewFile = strFilePath + cmbFIXVerDataDictionary.Text + extension;
XDocument xmldoc = XDocument.Load(strNewFile);
List<string> tags = new List<string>();
IEnumerable<string> childNames = (from child in xmldoc.Element("fix").Element("fields").Descendants("field")
select child.Attribute("name").Value).Distinct().ToList();
foreach (string childName in childNames)
{
if (childName.StartsWith(typedString, StringComparison.InvariantCultureIgnoreCase))
{
tags.Add(childName);
}
}
txtCustomTagName.ItemsSource = tags;
}
}
Как это сделать?