There are two things i want to do with MVVMLight but I don't know where to start.
- Serialise an XML file as a viewmodel or use as a datasource
Would you recommend a different format (i can change at this point), I can't find any tutorials for mvvmlight relating to setting up a datasource initially.
- Use a different layout depending on a particular type of record in the xml file
i'm considering using switch statements to hide/show and reorganise everything programmatically but it doesn't seem right.
I currently use linq to read into a model, but without using MVVMlight (will this still work with MVVM?)
public IEnumerable<Quiz.Question> LoadQuestions()
{
XDocument questionData = XDocument.Load("questions.xml");
var data = from query in questionData.Descendants("question")
select new Quiz.Question
{
QuestionTitle = (string)query.Attribute("title"),
QuestionText = query.Element("text") != null ? query.Element("text").Value.Trim() : string.Empty,
QuestionImage = query.Element("image") != null ? query.Element("image").Attribute("src").Value : string.Empty
};
var shuffledData = Enumerable.Shuffle<Quiz.Question>(data);
return shuffledData;
}