I have spent 2 days on this problem and still have not solved this...
The Json comes from Firebase Realtime Database.
My absolute goal would be to get the key (Zaptec) as name in the class instead of having to create a "name" property. But that is a question for another day I quess.
My Output:
Name = My Watchlist
Stocks = Models.StocksModel (but value is null)
{
"name": "My Watchlist",
"stocks": {
"Zaptec": {
"avgPrice": "2,14",
"name": "Zaptec",
"shares": 121
}
}
}
public class WatchlistModel : INotifyPropertyChanged
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; OnPropertyChanged("Name"); }
}
private StocksModel _stocks;
public StocksModel Stocks
{
get { return _stocks; }
set { _stocks = value; OnPropertyChanged("Stocks"); }
}
}
public class StocksModel : INotifyPropertyChanged
{
private StockModel _stocks;
public StockModel Stocks
{
get { return _stocks; }
set { _stocks = value; OnPropertyChanged("Stocks"); }
}
}
public class StockModel : INotifyPropertyChanged
{
#region -- Properties --
private string _name;
public string Name
{
get { return _name; }
set { _name = value; OnPropertyChanged("Name"); }
}
private string _avgPrice;
public string AvgPrice
{
get { return _avgPrice; }
set { _avgPrice = value; OnPropertyChanged("AvgPrice"); }
}
private string _shares;
public string Shares
{
get { return _shares; }
set { _shares = value; OnPropertyChanged("Shares"); }
}
}