我想将每个已处理SelectedItem的 from添加ListView A为ListView B一种历史记录。如果我只为一个对象编写此代码,但当我尝试向其中添加另一个对象时,ListView B它没有显示任何内容。我知道我必须将其反序列化为 aList<obj>但它不起作用。你能帮我吗?
这是我到目前为止所尝试的:
// ListView A (Source)
// the ItemSelected is processed this function is called
public void AddToHistory(Object obj)
{
string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "history.txt");
var content = JsonConvert.SerializeObject(obj);
File.WriteAllText(fileName, content);
}
// ListView B (Destination View)
void CreateListOfObjects()
{
ObjectList = new List<Object>();
string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "history.txt");
var content = File.ReadAllText(fileName);
var json = JsonConvert.DeserializeObject<Object>(content);
ObjectList.Add(json);
}
private List<Object> _object;
public List<Object> ObjectList
{
get => _object;
set => SetValue(ref _object, value);
}
狐的传说
慕婉清6462132
相关分类