Click here to Skip to main content
15,888,062 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: textbox value Pin
Ed Hill _5_9-Jun-11 5:59
Ed Hill _5_9-Jun-11 5:59 
Questionany suggestions on how to deploy this MVVM model in Silverlight 4? Pin
Michael J. Eber6-Jun-11 12:11
Michael J. Eber6-Jun-11 12:11 
AnswerRe: any suggestions on how to deploy this MVVM model in Silverlight 4? Pin
Abhinav S6-Jun-11 22:29
Abhinav S6-Jun-11 22:29 
GeneralRe: any suggestions on how to deploy this MVVM model in Silverlight 4? Pin
Michael J. Eber7-Jun-11 7:47
Michael J. Eber7-Jun-11 7:47 
GeneralRe: any suggestions on how to deploy this MVVM model in Silverlight 4? Pin
Paul Daniel Ruston8-Jun-11 12:25
Paul Daniel Ruston8-Jun-11 12:25 
GeneralRe: any suggestions on how to deploy this MVVM model in Silverlight 4? Pin
Paul Daniel Ruston8-Jun-11 12:29
Paul Daniel Ruston8-Jun-11 12:29 
AnswerRe: any suggestions on how to deploy this MVVM model in Silverlight 4? Pin
RichardGrimmer10-Jun-11 4:55
RichardGrimmer10-Jun-11 4:55 
QuestionNewbie (but sort of advanced) Dependency Injection questions... Pin
SledgeHammer013-Jun-11 19:06
SledgeHammer013-Jun-11 19:06 
I use an MVVM / custom control library that I wrote myself. Right now it works like this at a high level:

* all view models are derived from ViewModelBase
* I have an attached Type property called ViewModel that gets specified something like:

<Window ...
MyMVVMLib::ViewModelBase.ViewModel="{x:Type local:Test}">
.
.
</Window>

My library creates an instance of local:Test and sets the Window.DataContext equal to that instance.

* At this point, all ViewModels must have a default parameterless constructor
* ViewModelBase also has a static ServiceLocator

I have not really used Dependency Injection before, but it is my understanding that my current code looks like this:

public class Test : ViewModelBase
{
public Test()
{
ServiceLocator.GetService<IFoo1>();
ServiceLocator.GetService<IFoo2>();
}
}

vs. Dependency Injection which looks something like:

public class Test : ViewModelBase
{
public Test(IFoo1 foo1, IFoo2 foo2)
{
}
}

at some point early in the start up, you are supposed to register the interface <-> implementation class mappings?

So if I want to add DI support to my MVVM lib, it is my understanding that the ViewLocator needs to go through the params in the constructor and match up the interfaces with the classes that you registered.

I am **NOT** interested in using a DI lib that somebody else wrote like Unity, etc. I am interested in knowing how they work and implementing my own.

Seems like the requirement is that you have a single public constructor? Some libs I have seen add a custom attribute like [DependencyInjection] or [Ninject] to the one constructor that you want the DI to happen on? What is the best approach?

Are these libs using reflection to go through the constructor params? Or some other cool mechanism for which I am unaware?

I assume there is some kind of caching going on? Like, it only needs to go through the reflection once and then caches the interfaces and the order of which they are passed in?

Last question for now... seems like ServiceLocator, you pass in the type and a class instance to register, but in DI, you pass in an interface type and a class instance type?
AnswerRe: Newbie (but sort of advanced) Dependency Injection questions... Pin
Abhinav S6-Jun-11 2:36
Abhinav S6-Jun-11 2:36 
GeneralRe: Newbie (but sort of advanced) Dependency Injection questions... Pin
SledgeHammer016-Jun-11 6:58
SledgeHammer016-Jun-11 6:58 
AnswerRe: Newbie (but sort of advanced) Dependency Injection questions... Pin
James McConville6-Jun-11 3:39
James McConville6-Jun-11 3:39 
GeneralRe: Newbie (but sort of advanced) Dependency Injection questions... Pin
SledgeHammer016-Jun-11 6:53
SledgeHammer016-Jun-11 6:53 
GeneralRe: Newbie (but sort of advanced) Dependency Injection questions... Pin
James McConville6-Jun-11 22:21
James McConville6-Jun-11 22:21 
QuestionNeed to register click event for a Checkbox in side WPF Datagrid using MVVM Pin
Yogesh Jamkhindikar3-Jun-11 15:11
Yogesh Jamkhindikar3-Jun-11 15:11 
AnswerRe: Need to register click event for a Checkbox in side WPF Datagrid using MVVM Pin
Mycroft Holmes3-Jun-11 16:46
professionalMycroft Holmes3-Jun-11 16:46 
QuestionAttempted to read or write protected memory. This is often an indication that other memory is corrupt. Pin
Vimalsoft(Pty) Ltd3-Jun-11 0:03
professionalVimalsoft(Pty) Ltd3-Jun-11 0:03 
QuestionIs it possible to databind from a window.resources section? Pin
SledgeHammer012-Jun-11 6:37
SledgeHammer012-Jun-11 6:37 
AnswerRe: Is it possible to databind from a window.resources section? Pin
Ian Shlasko2-Jun-11 7:23
Ian Shlasko2-Jun-11 7:23 
GeneralRe: Is it possible to databind from a window.resources section? Pin
SledgeHammer012-Jun-11 7:34
SledgeHammer012-Jun-11 7:34 
QuestionSilverlight identification from server side Pin
bhavnvyas1-Jun-11 23:56
bhavnvyas1-Jun-11 23:56 
AnswerRe: Silverlight identification from server side Pin
Pete O'Hanlon2-Jun-11 0:57
mvePete O'Hanlon2-Jun-11 0:57 
AnswerRe: Silverlight identification from server side Pin
Abhinav S3-Jun-11 18:33
Abhinav S3-Jun-11 18:33 
QuestionHow to get new coordinates after a Rotation Pin
Suresh Suthar31-May-11 20:09
professionalSuresh Suthar31-May-11 20:09 
AnswerRe: How to get new coordinates after a Rotation Pin
_Maxxx_31-May-11 23:45
professional_Maxxx_31-May-11 23:45 
QuestionNeed Silverlight 3d chart Pin
Mikhael Ray Burton31-May-11 12:44
Mikhael Ray Burton31-May-11 12:44 

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.