Click here to Skip to main content
15,897,273 members
Home / Discussions / WPF
   

WPF

 
QuestionXmlDocument Pin
arkiboys18-Feb-11 5:26
arkiboys18-Feb-11 5:26 
AnswerRe: XmlDocument Pin
Abhinav S18-Feb-11 6:12
Abhinav S18-Feb-11 6:12 
GeneralRe: XmlDocument Pin
#realJSOP19-Feb-11 2:35
professional#realJSOP19-Feb-11 2:35 
AnswerRe: XmlDocument Pin
#realJSOP19-Feb-11 2:34
professional#realJSOP19-Feb-11 2:34 
GeneralRe: XmlDocument Pin
Abhinav S19-Feb-11 3:14
Abhinav S19-Feb-11 3:14 
QuestionAccess xml file from .xaml page Pin
arkiboys18-Feb-11 5:16
arkiboys18-Feb-11 5:16 
AnswerRe: Access xml file from .xaml page Pin
Abhinav S18-Feb-11 6:24
Abhinav S18-Feb-11 6:24 
QuestionMVVM: Best Practices and Design Patterns Pin
IngoVals18-Feb-11 4:54
IngoVals18-Feb-11 4:54 
While the title is somewhat generic I would love to disucss this as a beginner with experienced MVVM users and other beginners as well.

I have created a WPF app mostly ignoring MVVM, at least to begin with. I have now decided to refactor it and use MVVM. I'm hoping to make it better and easier to manage. However there are several things I'm not 100% certain about how to implement some things in MVVM. I guess there isn't just one way but I would love to hear what you like to do and how. I'm adding numbered discussion points here to better catagorize. If others have questions or thoughts to add please be welcome.

1) Most MVVM examples are quite simple. In reality it can be quite different. For example I often have objects that include a number of other objects which also include other objects. So there is a View where users could choose an object from a list, see detailed info about it and also a list of objects that are it's children. They could then choose a child object and get detailed info about it as well.

How does this apply as ViewModels. Is it a single viewmodel that includes everything, or a viewmodel that opens another different viewmodel. I would like to have the child object as it's own ViewModel/UserControl - View and have the parent able to show this UserControl within it's own.

Would you rather have the child inside the parents viewmodel or seperate but linked?

Can you point out examples or books that investigates this?

2) iEditableObject, I've used this interface on my objects and it works with CollectionViews. I haven't really seen it mention in MVVM. It means a object can basically be in a EditMode and you can rollback changes made and such. Now in my program when you look at the details of a object they are static, meaning you can't change text (it's textBlocks not TextBox), then you press a EDIT button and you get the edit look. I've done this by switching out the dataTemplate for the object. However that seems to mean logic inside Xaml. I guess I could do it in code, or just have seperate UserControls and swithc them out

Also this handles well adding new items to collections but I haven't seen this used in any MVVM example I've seen. Could you point out any?

3) If many apps are getting the data from the same place, and they can change that data. How do you keep the data current. Do you reload it regulary, use ActiveRecord pattern. I guess this has nothing to do with MVVM but I'm fishing out what people have used alongwith MVVM with good results.

4) Can you use LINQ entity items with any good results, like perhaps populating the viewmodel with them? It's not proper to keep the context open but having the object itself might help with saving back to database. What happens to a LINQ object when the Context is closed. Do I still have access to it's relative tables an such.

5) I'm very often showing objects as lists+details for the selected object (master detail view). However the details between objects can be somewhat different. I guess I could make a abstract ViewModel for their common functionality but what about the Views themselves. It will have the same buttons, the same format showing the list and then the details. Basicly the only difference will be the fields in the detail. I can't make a abstract UserControl (except without the XAML). How to solve this? Using styles, ControlTemplates? Again any examples out there I could check out?

I'll probably have million other questions but this is enough for now. If anyone can answer or just point towards something with good answers/examples I would be very happy.

Most of what I know about MVVM comes from http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
AnswerRe: MVVM: Best Practices and Design Patterns Pin
Abhinav S18-Feb-11 6:20
Abhinav S18-Feb-11 6:20 
AnswerRe: MVVM: Best Practices and Design Patterns Pin
SledgeHammer0118-Feb-11 6:56
SledgeHammer0118-Feb-11 6:56 
AnswerRe: MVVM: Best Practices and Design Patterns Pin
BubingaMan22-Feb-11 4:35
BubingaMan22-Feb-11 4:35 
QuestionOpen WPF Application from within Excel Add-In Pin
muelito18-Feb-11 3:18
muelito18-Feb-11 3:18 
Question2 different styles - 2 different objects - both affected the same way??? Pin
bigwillyca17-Feb-11 6:35
bigwillyca17-Feb-11 6:35 
AnswerRe: 2 different styles - 2 different objects - both affected the same way??? Pin
dasblinkenlight18-Feb-11 3:06
dasblinkenlight18-Feb-11 3:06 
GeneralRe: 2 different styles - 2 different objects - both affected the same way??? Pin
bigwillyca18-Feb-11 5:02
bigwillyca18-Feb-11 5:02 
QuestionHow to sort the items under some node in Silverlight tree view? Pin
Tesic Goran17-Feb-11 3:20
professionalTesic Goran17-Feb-11 3:20 
AnswerRe: How to sort the items under some node in Silverlight tree view? Pin
SledgeHammer0117-Feb-11 7:14
SledgeHammer0117-Feb-11 7:14 
GeneralRe: How to sort the items under some node in Silverlight tree view? Pin
Tesic Goran17-Feb-11 19:35
professionalTesic Goran17-Feb-11 19:35 
Answersymbols not loaded Pin
cmichaelgraham17-Feb-11 3:04
cmichaelgraham17-Feb-11 3:04 
GeneralRe: symbols not loaded Pin
SledgeHammer0117-Feb-11 7:12
SledgeHammer0117-Feb-11 7:12 
GeneralRe: symbols not loaded Pin
Abhinav S17-Feb-11 17:49
Abhinav S17-Feb-11 17:49 
QuestionHow to restyle tab control in WPF Pin
Tridip Bhattacharjee16-Feb-11 23:09
professionalTridip Bhattacharjee16-Feb-11 23:09 
AnswerRe: How to restyle tab control in WPF Pin
SledgeHammer0117-Feb-11 7:10
SledgeHammer0117-Feb-11 7:10 
QuestionOpen a new Window from a Page in silverlight 4.0 Pin
Member-495917616-Feb-11 22:54
Member-495917616-Feb-11 22:54 
AnswerRe: Open a new Window from a Page in silverlight 4.0 Pin
#realJSOP17-Feb-11 7:11
professional#realJSOP17-Feb-11 7:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.