칩옵니다 칩 나는 텍스트 상자의 예에서 목록 상자를 추가 할 필요가
은 스크린 샷을 참조하십시오
을public class Person
{
private ObservableCollection<string> _personList = new ObservableCollection<string>();
public ObservableCollection<string> PersonList
{
get { return _personList; }
set
{
_personList = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("PersonList"));
}
}
private string _personStr = String.Empty;
public string PersonStr
{
get { return _personStr; }
set
{
_personStr = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("PersonStr"));
}
}
public Person()
{
PersonList.Add("IR-Punch");
PersonList.Add("Stack-Overflow");
}
public ICommand BTextCommand
{
get
{
return new DelegateCommand(AppendString);
}
}
public void AppendString()
{
PersonList.Add(PersonStr);
}
}
작동하는 XAML 소스 코드 :
<ItemsControl ItemsSource="{Binding PersonList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding }" TextWrapping="Wrap"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBox Text="{Binding PersonStr}" Width="160" VerticalAlignment="Center" />
<Button Command="{Binding BTextCommand}" Content="Add" />
TextBox
내에 ListBox
을 추가하는 것이 친절히 도움이됩니다. 나는시 틀을 돌봐. 나는 핵심 아이디어를 기대하고있다. 아래 그림과 같이
코드에서 시도 할 수 있고 프로그래밍 방식으로 TextBox 내에 ListBox를 추가 할 수 있습니다. –
그 글을 쓰는 방법을 묻는 아이디어입니다 ... –
여기에 묻는 것은 약간 명확하지 않습니다. 텍스트 상자에 입력을 시작하고 드롭 다운에 옵션 목록을 표시 하시겠습니까? – Stewbob