请有人告诉我为什么我的组合框没有填充?
请注意以下事项: _memberReference从另一个表单传递。 为了简洁,省略了另一个组合框。 枚举正确填充下拉框。 这是来自SQL表的数据没有显示在组合框中。我缺少什么?
<Window.Resources>
<ObjectDataProvider x:Key="pa_enum"
MethodName="GetValues"
ObjectType="{x:Type core:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type Type="local2:PossibleAnswerEnum"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ComboBox x:Name="cmbQ1"
FontSize="16"
Margin="5"
Grid.Row="0"
Grid.Column="4"
Grid.ColumnSpan="1"
ItemsSource="{Binding Source={StaticResource pa_enum}}"
SelectedValue="{Binding Q1}">
public partial class ExtractionForm : Window
{
public string Type;
public string SelectedMemberReference;
public string ts;
public ExtractionForm(string _memberReference)
{
InitializeComponent();
var obj = DataRepository.GetMemberDetails(_memberReference);
DGMemberDetails.ItemsSource = obj;
SelectedMemberReference = _memberReference;
var RecordsUpdated = DataRepository.GetMember(SelectedMemberReference);
DataContext = RecordsUpdated;
ts = UserInfo.GetTimeStamp();
}
}
public static ObservableCollection<ExtractedData> GetMember (string memberid)
{
var DataObj = new ObservableCollection<ExtractedData>();
var dt = StoredProcedure.GetMemberData("dbo.ExtractedData", memberid);
foreach (DataRow dr in dt.Rows)
{
DataObj.Add(new ExtractedData()
{
MemberReference = dr["MemberReference"].ToString(),
Q1 = dr["Question1"].ToString(),
Q2 = dr["Question2"].ToString()
});
}
return DataObj;
}
public class ExtractedData: INotifyPropertyChanged
{
private string memberReference;
private string q1;
private string q2;
private PossibleAnswerEnum possibleanswer;
public string MemberReference
{
get { return memberReference; }
set
{
memberReference = value;
RaisePropertyChanged(); ;
}
}
public string Q1
{
get { return q1; }
set
{
q1 = value;
RaisePropertyChanged(); ;
}
}
public string Q2
{
get { return q2; }
set
{
q2 = value;
RaisePropertyChanged(); ;
}
}
public PossibleAnswerEnum PossibleAnswer
{
get
{
return possibleanswer;
}
set
{
possibleanswer = value;
RaisePropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(
[CallerMemberName] string caller = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(caller));
}
}
public enum PossibleAnswerEnum
{
Yes,
No,
Unclear
}