好吧,所以我花了幾個小時,試圖找出這一點,我不能。 我有下面的組合框,它正確地綁定到我的數據收集。選定的價值組合框沒有約束力
<ComboBox Name="cbx" Width="250" Height="25"
Visibility="{Binding Path=IsComboBox,Converter={StaticResource BoolConverter}}"
ItemsSource="{Binding Path=Answers}"
SelectedValuePath="AnswerId"
SelectedItem="{Binding Path=SelectedAnswer, Mode=TwoWay}"
DisplayMemberPath="Answer"/>
然而,選定的項目並未填充到我選擇的答案屬性的頂部。我在窗體上放置了一個文本框並將其綁定到了SelectedAnswer.Answer,並且正確地綁定了答案。 出於某種原因,儘管我的組合框不會選擇的答案
- 我看過一些有關組合框屬性的佈局,並試圖改變結合,還可以通過屬性的getter和setter加強,以確保它沒有清理(這不像它會綁定到文本框)
請幫助這一點。
SurveyAnswer:
public class SurveyAnswer : INotifyPropertyChanged
{
private Guid answerId;
public Guid AnswerId
{
get { return answerId; }
set {
answerId = value;
NotifyPropertyChanged("AnswerId");
}
}
private string answer;
public string Answer
{
get { return answer; }
set {
answer = value;
NotifyPropertyChanged("Answer");
}
}
public Guid SurveyLineID { get; set; }
private bool isSelected;
public bool IsSelected
{
get { return isSelected; }
set {
isSelected = value;
NotifyPropertyChanged("IsSelected");
}
}
#region NotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
#endregion
}
你能後如何填充了'Answers'收集和'SelectedAnswer'財產,也是'SelectedAnswer'財產的執行? – nemesv 2012-01-05 15:56:41