は、WPFからAutoCompleteTextBoxための「アイテムソースの」セットアップ私はWPFの基本バージョンでは、あなたは、ドロップダウンのオプションのためのItemSourceでコンボボックスを設定することができることを知っている:トラブル拡張ツールキット
ComboBox box = new ComboBox();
box.ItemSource = List<string> exampleList;
WPF Extended Toolkitを使用してAutoCompleteTextBoxで同じ機能を試していますが、 "Item Source"プロパティはありません。私は過去数日間オンラインの例を見てきましたが、提案リストが生成されている例はまだ見つかりません。私は適切にツールキットの名前空間を含めるように私のXAMLを設定していると、実際のテキストボックスには罰金を示しています。
<Window x:Class="complianceAuthApp.MainWindow"
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"
xmlns:local="clr-namespace:complianceAuthApp"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="Authorization Submission App" Height="290" Width="747" Closing="Window_Closing" ResizeMode="CanMinimize">
<grid>
...
<xctk:AutoSelectTextBox
Name="lastNameAutoTextBox"
AutoWordSelection="True"
BorderBrush="DarkGray"
AutoSelectBehavior="OnFocus"
Margin="21,35,586,193"/>
</Grid>
</Window>
はしかし、私は、テキストボックス内の文字の数が3以上に達するたびにSQLクエリを実行したい:
public void getAutoTextBoxItemSource()
{
if (lastNameAutoTextBox.Text.Length < 3)
return;
List<string> results = new List<string>();
SqlConnection cnn = new SqlConnection(ConfigurationManager["SQLQuery"].ConnectionString);
string sqlCommand = "SELECT TOP 10 ... ";
cnn.Open();
SQL.DataSet ds = new SQL.DataSet();
SQL.DataTable dtable = new SQL.DataTable();
SqlDataAdapter dscmd = new SqlDataAdapter(sqlCommand, cnn);
int t = await Task.Run(() => dscmd.Fill(dtable));
foreach (SQL.DataRow row in dtable.Rows)
{
results.Add(new string);
}
//If there WERE to be an ItemSource Property...
lastNameAutoTextBox.ItemSource=results;
}
}
私のニーズに合ったサンプルを見つけることができず、過去数日間、この方法でプロジェクトを実装する方法を理解しようとしています。
さて、明らかになっていたはずのことを指摘していただきありがとうございます。私はちょうど20分前に、テキストボックスが私が思っていたものとは異なる意図された目的を持っていることを認識しました。私はこのライブラリを調べ、試してみます。ありがとうございました! – Rinktacular