You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-5Lines changed: 29 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ MaterialDesignInXaml has great support for dialogs, but it's not clear how to us
11
11
-`Dialog`: a generic dialog imlpementation with title, message and configurable buttons which should suit 99% of your dialog use-cases.
12
12
-`ButtonDef`: A simple model for dialog buttons. Includes a label, a "connotation" (Positive, Negative, or Neutral) which determines how the button is drawn, and a couple properties to make the button activate on [Enter] or [Esc].
13
13
14
-
###Basic dialog
14
+
## Basic dialog
15
15
16
16
Here's the code for the above screenshot:
17
17
```
@@ -22,12 +22,36 @@ ButtonDef result = await this.ShowDialogForResultAsync( new Dialogs.Dialog( "Que
Our example dialog in this case implements `IHasDialog<ButtonDef>`, meaning the result will be one of the three buttons you passed in. But your dialog can return anything you like.
25
+
It uses the built-in, generic `Dialog` class to show a title, message and three buttons. The `Dialog` class implements `IHasDialog<ButtonDef>`, meaning the result will be one of the buttons you passed in. If you write your own dialog, you can return anything you like.
26
26
27
-
### Custom dialog
27
+
The built-in dialog requires a couple custom styles. If you want to use it, make sure you put the following in your `App.xaml` to import them:
### Basic dialog: Button connotations and restyling buttons
33
+
34
+
When defining buttons for the built-in dialog, you have 3 `Connotations`:
35
+
-`Connotations.Neutral`: Used for an action with no side effects, like "Cancel" or "Continue". The style for this is `MaterialDesign.DialogPlus.NeutralButton` which is an outlined button with the primary theme color.
36
+
-`Connotations.Positive`: Used for positive actions, such as acknowledging a message or saving a file. The style for this is `MaterialDesign.DialogPlus.PositiveButton` which is a raised button with the primary theme color.
37
+
-`Connotations.Negative`: Used for destructive actions, such as discarding changes or deleting a message. The style for this is `MaterialDesign.DialogPlus.NegativeButton` which is an outlined button with the outline and text color set to `MaterialDesignValidationErrorBrush` which is reddish in color.
38
+
39
+
You can change how any of these buttons are rendered in the built-in `Dialog` by defining your own style with the same name. Just put this in your `App.xaml` after you import the default button styles. For example:
Now buttons created with `ButtonDef.Negative()` will have a salmon-colored border and background.
48
+
49
+
## Custom dialog
50
+
51
+
The built-in `Dialog` class should suit 99% of use cases. But you can build a completely custom dialog if you like.
28
52
29
-
1. Create a `UserControl`. Design the dialog XAML however you like.
30
-
2. Make your dialog implement `IHasDialogResult<T>` with the desired result type. For example, if your dialog is a text input, you might implement `IHasDialogResult<string>`.
53
+
1. Create a `UserControl`. Write the dialog XAML and the code-behind however you like.
54
+
2. Make the `UserControl` implement `IHasDialogResult<T>` with the desired result type. For example, if your dialog is a text input, you might implement `IHasDialogResult<string>`.
31
55
3. To close your dialog, call `Result.Set` with the dialog result (for the text input example, this might be the user-input text, or `null` if the user canceled the dialog).
32
56
33
57
Check out the [main file](MaterialDesign.DialogPlus.Examples/MainWindow.xaml.cs) of the example project for the following examples:
0 commit comments