как получить требуемые свойства в Observercollection
В примерах новые элементы добавляются в Observercollection вручную, проблема в том, что я хочу добавить данные из моего rootobject, где все они существуют и читаются из Json.
Main Page
ObservableCollection<Class1> rootobject { get; set; }
Class1 cs1 = new Class1();
public Detail detail { get; set; }
public MainPage()
{
this.InitializeComponent();
string FilePath = Path.Combine(Package.Current.InstalledLocation.Path, "Class1.json");
using (StreamReader file = File.OpenText(FilePath))
{
var json = file.ReadToEnd();
rootobject = JsonConvert.DeserializeObject<ObservableCollection<Class1>>(json);
//Color c = new Color();
var items = new List<Class1>();
items.Add(new Detail
{
icon_url = ?,
});
items.Add(new Gradient_Props
{
gradient_stop_1 = ?,
gradient_stop_2 = ?,
});
}
}
Class created special JSON as Class
public class Rootobject
{
public Class1[] Property1 { get; set; }
}
public class Class1
{
public string itemType { get; set; }
public string type { get; set; }
public string title { get; set; }
public Detail[] details { get; set; }
}
public class Detail : Class1
{
public string detail_type { get; set; }
public string itemType { get; set; }
public string fill_color { get; set; }
public Gradient_Props gradient_props { get; set; }
public string icon_url { get; set; }
public string resource_url { get; set; }
}
public class Gradient_Props : Class1
{
public string gradient_stop_1 { get; set; }
public string gradient_stop_2 { get; set; }
}
public class Color : Class1
{
public Color(string color)
{
color = this.title;
}
}
public class Icon : Class1
{
public Icon(Detail[] iconUrl)
{
iconUrl = this.details;
}
}