I am trying to use MVVM with a System Windows Form interface on an Excel VSTO plug in
I have created my API, and my model, and my view model
I have successfully tested that I can use OnPropertyChanged to update a label on the form
I am now trying to populate a CheckedListBox with a named property from a List object in the view model
While my code does not throw an error, it doesn't display the desired output either
This is a code sample from the View
projects_label.DataBindings.Add(new Binding("Text", Globals.ThisAddIn.TFSConfigViewModel, "LabelText"));
projects_list_box.DataBindings.Add(new Binding("Text", Globals.ThisAddIn.TFSConfigViewModel, "ListOfProjectsFromVM.value.name"));
The first example works fine. The second doesn't display the text in the list
I would have thought the Property would be 'Label' but I get an error on anything but 'Text'
This is the model
public class TFS_Project
{
public string id { get; set; }
public string name { get; set; }
public string description { get; set; }
public string url { get; set; }
public string state { get; set; }
public int revision { get; set; }
public string visibility { get; set; }
}
public class TFS_Projects
{
public int count { get; set; }
public List<TFS_Project> value { get; set; }
}
This is from the View Model
public Models.TFS_Projects ListOfProjectsFromVM
{
get
{
return _listOfProjectsFromVM;
}
set
{
_listOfProjectsFromVM = value;
OnPropertyChanged(nameof(ListOfProjectsFromVM));
}
}
question from:
https://stackoverflow.com/questions/65919009/system-windows-forms-binding-list-of-items-to-list-view-control 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…