Skip to content
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
Merged

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

merged 2 commits into from May 29, 2015

Conversation

@ButchersBoy
Copy link
Contributor

@ButchersBoy 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
Copy link
Contributor Author

@ButchersBoy 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
add mechanism for easy access of a dialog from a view model
@punker76 punker76 merged commit 25ddbbf into MahApps:master May 29, 2015
@flagbug
Copy link
Member

@flagbug 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
Copy link
Member

@punker76 punker76 commented May 30, 2015

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

@ButchersBoy
Copy link
Contributor Author

@ButchersBoy 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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants