0
我是WPF的新手。我有自動完成框。當我輸入搜索文本時,下拉列表被填充。它包含項目。我可以選擇這些項目並通過下載保存到數據庫中。但項目不可見。這裏是我的代碼AutoCompleteBox的Dropdownlist項目不顯示在WPF
<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;
}
}
如何做到這一點?