New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mechanism for easy access of a dialog from a view model #1943

Merged
merged 2 commits into from May 29, 2015

Conversation

Projects
None yet
3 participants
@ButchersBoy
Contributor

ButchersBoy commented May 29, 2015

Using this mechanism you can easily use the MahApps dialogs from a view model. It is agbostic to whatever DI framework you may or may not be using.

To use you add an attached property in your XAML, which will tie the Binding (your view model) to the Window:

Dialog:DialogParticipation.Register="{Binding}"

Then the DialogCoordinator can be called from your view model, providing it with a context (your view model), it will know which Window to use to show the dialog.

_dialogCoordinator.ShowInput(this).ContinueWith(t => Console.WriteLine(t.Result));

outstanding: I've added to the demo app, but only a single dialog type right now. If you accept this PR I will build out the interface for the other dialog types.

@ButchersBoy

This comment has been minimized.

Contributor

ButchersBoy commented May 29, 2015

image

@punker76 punker76 added this to the 1.2.0 milestone May 29, 2015

punker76 added a commit that referenced this pull request May 29, 2015

Merge pull request #1943 from ButchersBoy/master
add mechanism for easy access of a dialog from a view model

@punker76 punker76 merged commit 25ddbbf into MahApps:master May 29, 2015

@flagbug

This comment has been minimized.

Member

flagbug commented May 30, 2015

This will totally lock us in to a fixed amount of different dialogs.

Because of API versioning, we now can't add for example a ShowCoolNewDialogAsync.

@punker76

This comment has been minimized.

Member

punker76 commented May 30, 2015

@flagbug i think there is no need to implement more special dialogs, cause we have custom dialog...

@ButchersBoy

This comment has been minimized.

Contributor

ButchersBoy commented May 30, 2015

Yeah, you have custom dialogs, and also, the new interface is only a facade onto the existing methods on the window...don't see how that would cause lock in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment