Skip to content
Discussion options

You must be logged in to vote

In my projects I usually create a dummy DI container and then do something like Design.DataContext={markup:DesignResolve {x:Type vm:MainViewModel}}, with a custom markup extension that resolves view models from the dummy container.

I believe it could be simpler, for example by creating a base class for views or overriding the default value for Design.DataContextProperty.

Additionally, if you want to use DI with views as well, I think overriding the default value for Design.PreviewWithProperty would work.

Replies: 4 comments 30 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@timunie
Comment options

timunie Nov 27, 2023
Collaborator

Comment options

You must be logged in to vote
28 replies
@thevortexcloud
Comment options

@timunie
Comment options

timunie Nov 27, 2023
Collaborator

@thevortexcloud
Comment options

@jp2masa
Comment options

Answer selected by maxkatz6
@thevortexcloud
Comment options

@timunie
Comment options

timunie Nov 28, 2023
Collaborator

@thevortexcloud
Comment options

@leowest77
Comment options

Comment options

You must be logged in to vote
1 reply
@thevortexcloud
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
9 participants
Converted from issue

This discussion was converted from issue #13742 on November 27, 2023 00:16.