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
Dialogs are a way to prompt a user for information or to allow for customizations of feature behavior. For example, the Tools/Options dialog has individual pages that let the user control the behavior for features like themes, editors, and document tabs.
15
+
Dialogs are a way to prompt a user for information or to allow for customizations of feature behavior. For example, the **Tools** > **Options** dialog has individual pages that let the user control the behavior for features like themes, editors, and document tabs.
16
16
17
17
## Get started
18
18
19
-
To get started, follow the [create the project](./../get-started/create-your-first-extension.md) section in the Getting Started section.
19
+
To get started, follow the steps in [Create your first Visual Studio extension](./../get-started/create-your-first-extension.md).
20
20
21
21
## Work with dialogs
22
22
23
-
This guide is designed to cover the top user scenarios when working with dialogs:
23
+
This article covers the top user scenarios when you work with dialogs:
24
24
25
25
-[Create a dialog](#create-a-dialog)
26
26
-[Customize the dialog title](#customize-the-dialog-title)
@@ -29,9 +29,9 @@ This guide is designed to cover the top user scenarios when working with dialogs
29
29
30
30
## Create a dialog
31
31
32
-
Creating a tool window with the new Extensibility Model is as simple as calling the [ShowDialogAsync](/dotnet/api/microsoft.visualstudio.extensibility.shell.shellextensibility.showdialogasync) method from the [ShellExtensibility](/dotnet/api/microsoft.visualstudio.extensibility.shell.shellextensibility) helpers and passing in your dialog content.
32
+
Creating a tool window with the new Extensibility model is as simple as calling the [ShowDialogAsync](/dotnet/api/microsoft.visualstudio.extensibility.shell.shellextensibility.showdialogasync) method from the [ShellExtensibility](/dotnet/api/microsoft.visualstudio.extensibility.shell.shellextensibility) helpers and passing in your dialog content.
33
33
34
-

34
+

35
35
36
36
### ShowDialogAsync
37
37
@@ -48,50 +48,50 @@ The [ShowDialogAsync](/dotnet/api/microsoft.visualstudio.extensibility.shell.she
48
48
49
49
| Name | Type | Description |
50
50
| ---- | ---- | ----------- |
51
-
| content |[Microsoft.VisualStudio.RpcContracts.RemoteUI.IRemoteUserControl](/dotnet/api/microsoft.visualstudio.rpccontracts.remoteui.iremoteusercontrol'Microsoft.VisualStudio.RpcContracts.RemoteUI.IRemoteUserControl')| The content of the dialog. |
52
-
| title |[System.String](/dotnet/api/System.String'System.String')| The title of the dialog. |
53
-
| options | Microsoft.VisualStudio.RpcContracts.Notifications.DialogOption | The options for displaying the dialog. |
54
-
| cancellationToken |[System.Threading.CancellationToken](/dotnet/api/System.Threading.CancellationToken'System.Threading.CancellationToken')| A [CancellationToken](/dotnet/api/System.Threading.CancellationToken'System.Threading.CancellationToken') to cancel the dialog. |
51
+
|`content`|[Microsoft.VisualStudio.RpcContracts.RemoteUI.IRemoteUserControl](/dotnet/api/microsoft.visualstudio.rpccontracts.remoteui.iremoteusercontrol'Microsoft.VisualStudio.RpcContracts.RemoteUI.IRemoteUserControl')| The content of the dialog. |
52
+
|`title`|[System.String](/dotnet/api/System.String'System.String')| The title of the dialog. |
53
+
|`options`|`Microsoft.VisualStudio.RpcContracts.Notifications.DialogOption`| The options for displaying the dialog. |
54
+
|`cancellationToken`|[System.Threading.CancellationToken](/dotnet/api/System.Threading.CancellationToken'System.Threading.CancellationToken')| A [CancellationToken](/dotnet/api/System.Threading.CancellationToken'System.Threading.CancellationToken') to cancel the dialog. |
// Ownership of the RemoteUserControl is transferred to Visual Studio, so it shouldn't be disposed by the extension
80
-
#pragmawarningdisable CA2000 // Dispose objects before losing scope
79
+
// Ownership of the RemoteUserControl is transferred to Visual Studio, so it shouldn't be disposed by the extension.
80
+
#pragmawarningdisable CA2000 // Dispose of objects before losing scope.
81
81
var control = new MyDialogControl(null);
82
-
#pragmawarningrestore CA2000 // Dispose objects before losing scope
82
+
#pragmawarningrestore CA2000 // Dispose of objects before losing scope.
83
83
84
84
awaitthis.Extensibility.Shell().ShowDialogAsync(control, "My Dialog Title", cancellationToken);
85
85
}
86
86
```
87
87
88
88
## Customize the dialog buttons
89
89
90
-
When a dialog is shown in the IDE, certain combinations of predefined dialog buttons and default actionscan be selected. The predefined button and action combinations can be found in `Microsoft.VisualStudio.RpcContracts.Notifications.DialogOption`.
90
+
When a dialog is shown in the integrated development environment, you can select certain combinations of predefined dialog buttons and default actions. You can find the predefined button and action combinations in `Microsoft.VisualStudio.RpcContracts.Notifications.DialogOption`.
91
91
92
-

92
+

93
93
94
-
Additionally, you can create your own combination of buttons and default actions from:
94
+
You can also create your own combination of buttons and default actions from:
If you need to know whether a user affirmatively closed a dialog or dismissed it, you can await the call to [`ShowDialogAsync`](/dotnet/api/microsoft.visualstudio.extensibility.shell.shellextensibility.showdialogasync), and it will return a`Microsoft.VisualStudio.RpcContracts.Notifications.DialogResult`, which represents the action taken by the user.
163
+
If you need to know whether a user affirmatively closed a dialog or dismissed it, you can await the call to [`ShowDialogAsync`](/dotnet/api/microsoft.visualstudio.extensibility.shell.shellextensibility.showdialogasync). It returns`Microsoft.VisualStudio.RpcContracts.Notifications.DialogResult`, which represents the action taken by the user.
// Ownership of the RemoteUserControl is transferred to Visual Studio, so it shouldn't be disposed by the extension
169
-
#pragmawarningdisable CA2000 // Dispose objects before losing scope
168
+
// Ownership of the RemoteUserControl is transferred to Visual Studio, so it shouldn't be disposed by the extension.
169
+
#pragmawarningdisable CA2000 // Dispose of objects before losing scope.
170
170
var control = new MyDialogControl(null);
171
-
#pragmawarningrestore CA2000 // Dispose objects before losing scope
171
+
#pragmawarningrestore CA2000 // Dispose of objects before losing scope.
172
172
173
173
DialogResultresult=awaitthis.Extensibility.Shell().ShowDialogAsync(control, "My Dialog Title", DialogOption.OKCancel, cancellationToken);
174
174
175
175
if (result==DialogResult.OK)
176
176
{
177
-
//User clicked the OK button
177
+
//The user selected the OK button.
178
178
}
179
179
}
180
180
```
181
181
182
-
## Next steps
182
+
## Related content
183
183
184
-
See the [DialogSample](https://github.com/Microsoft/VSExtensibility/tree/main/New_Extensibility_Model/Samples/DialogSample)sample for a full example of creating an extension with a dialog.
184
+
-See [DialogSample](https://github.com/Microsoft/VSExtensibility/tree/main/New_Extensibility_Model/Samples/DialogSample) for a full example of how to create an extension with a dialog.
0 commit comments