Dynamic content loading in Expander, WPF

427 Views Asked by At

I've a json file having a list of data. For eg

    {
    "data" : 
        { 
            "Name" : "Abc",
            "Desc" : "123"
        },
        { 
            "Name" : "Def",
            "Desc" : "456"
        }, 
        { 
            "Name" : "Ghi",
            "Desc" : "789"
        }
  }

So, what I need is a WPF application that would show a list of expanders with headers as Name as stated in Json and it's content as Desc.

Everything should be dynamically loaded. Also, initially only the names should be loaded onto expander's headers and all unexpanded. Only when user expands one of them, it should load that particular expander's description and display accordingly.

The last part is important as my json file is in MBs and performance is a real issue.

I'm able to parse all json and create dynamic list of expanders, but didn't find any approach for loading expander's content at run time.

I've tried this approach :

https://wpf.2000things.com/2013/09/26/915-delaying-generation-of-expander-content/

But I can't access the textblock using its name. Also, their names would coincide with other expanders, and I can't hard code them.

0

There are 0 best solutions below