From 25480ff84615b4437b42216a9af4a9a08c5fd023 Mon Sep 17 00:00:00 2001 From: David Coulter Date: Thu, 5 Nov 2020 11:04:06 -0800 Subject: [PATCH 1/5] Links: .NET Desktop - framework\winforms (#108) --- ...ecurity-considerations-in-windows-forms.md | 9 ++++-- .../application-settings-architecture.md | 12 ++++++-- .../application-settings-for-windows-forms.md | 4 ++- .../advanced/application-settings-overview.md | 7 +++-- ...-support-for-windows-forms-applications.md | 12 ++++++-- ...rop-by-displaying-a-windows-form-shadow.md | 4 ++- ...fects-of-modifying-base-form-appearance.md | 2 +- .../advanced/globalizing-windows-forms.md | 12 ++++---- ...e-an-elementhost-control-at-design-time.md | 2 +- .../how-to-create-application-settings.md | 4 ++- ...using-the-inheritance-picker-dialog-box.md | 4 +-- .../advanced/how-to-inherit-windows-forms.md | 8 ++--- ...a-multi-page-text-file-in-windows-forms.md | 5 +++- ...ing-each-windows-form-on-its-own-thread.md | 10 +++---- .../how-to-validate-application-settings.md | 2 +- ...etworking-in-windows-forms-applications.md | 5 +++- .../winforms/advanced/using-wpf-controls.md | 2 +- ...content-on-windows-forms-at-design-time.md | 2 +- ...content-on-windows-forms-at-design-time.md | 2 +- ...an-accessible-windows-based-application.md | 4 +-- ...content-on-windows-forms-at-design-time.md | 6 ++-- .../walkthrough-styling-wpf-content.md | 8 ++--- ...rms-and-unmanaged-applications-overview.md | 21 +++++++++----- ...indows-forms-and-unmanaged-applications.md | 8 +++-- .../windows-forms-visual-inheritance.md | 9 ++++-- ...on-to-a-treeview-or-listview-control-wf.md | 3 +- ...-wf-datagrid-control-using-the-designer.md | 2 +- .../attributes-in-windows-forms-controls.md | 6 +++- .../backgroundworker-component-overview.md | 9 +++--- .../controls/backgroundworker-component.md | 6 +++- ...data-to-the-datagrid-using-the-designer.md | 13 +++++---- ...bind-wf-controls-with-the-bindingsource.md | 3 +- ...rol-to-a-data-source-using-the-designer.md | 2 +- .../controls/button-control-windows-forms.md | 6 +++- ...ed-data-at-run-time-wf-datagrid-control.md | 3 +- ...ng-an-activex-control-on-a-windows-form.md | 8 ++--- .../controls/contextmenustrip-control.md | 6 +++- .../controls/control-type-recommendations.md | 4 +-- .../controls-to-use-on-windows-forms.md | 5 +++- ...-lookup-table-for-a-wf-combobox-listbox.md | 3 +- ...ter-detail-form-using-two-datagridviews.md | 8 +++-- ...-wf-datagrid-control-using-the-designer.md | 4 +-- ...ter-detail-form-using-two-datagridviews.md | 4 +-- ...ating-a-wf-control-design-time-features.md | 4 +-- ...-the-windows-forms-datagridview-control.md | 5 +++- ...ontrol-technology-summary-windows-forms.md | 10 ++++++- ...ng-a-property-in-windows-forms-controls.md | 7 +++-- ...ning-an-event-in-windows-forms-controls.md | 5 ++-- ...me-errors-in-the-windows-forms-designer.md | 8 ++--- ...oping-a-composite-windows-forms-control.md | 2 +- ...eveloping-custom-windows-forms-controls.md | 10 +++++-- ...g-windows-forms-controls-at-design-time.md | 6 ++-- .../events-in-windows-forms-controls.md | 5 ++-- ...umns-in-the-datagrid-using-the-designer.md | 3 +- ...occur-during-data-entry-in-the-datagrid.md | 8 +++-- ...occur-during-data-entry-in-the-datagrid.md | 4 +-- .../winforms/controls/handling-user-input.md | 7 +++-- ...-the-managed-html-document-object-model.md | 4 ++- ...-the-managed-html-document-object-model.md | 3 +- ...o-add-activex-controls-to-windows-forms.md | 6 ++-- .../how-to-add-controls-to-windows-forms.md | 5 ++-- ...thout-a-user-interface-to-windows-forms.md | 4 +-- ...ow-to-add-panels-to-a-statusbar-control.md | 3 +- ...om-a-collection-of-controls-at-run-time.md | 3 +- ...ly-attributes-in-windows-forms-controls.md | 9 +++++- ...-the-windows-forms-datagridview-control.md | 8 ++--- ...ows-forms-folderbrowserdialog-component.md | 2 +- ...a-resizable-windows-form-for-data-entry.md | 5 +++- ...ndows-forms-control-that-shows-progress.md | 4 ++- ...yout-that-responds-well-to-localization.md | 13 +++++---- ...-develop-a-simple-windows-forms-control.md | 8 ++--- ...-in-the-choose-toolbox-items-dialog-box.md | 4 +-- ...h-the-windows-forms-richtextbox-control.md | 2 +- ...-the-windows-forms-datagridview-control.md | 8 +++-- ...rms-datagrid-control-using-the-designer.md | 4 +-- ...a-form-that-uses-a-background-operation.md | 9 ++++-- ...it-from-existing-windows-forms-controls.md | 2 +- .../how-to-inherit-from-the-control-class.md | 2 +- ...w-to-inherit-from-the-usercontrol-class.md | 2 +- ...des-of-a-windows-forms-treeview-control.md | 3 +- ...o-the-windows-forms-richtextbox-control.md | 2 +- ...ad-safe-calls-to-windows-forms-controls.md | 4 +-- ...iles-using-the-openfiledialog-component.md | 4 +-- ...w-to-position-controls-on-windows-forms.md | 2 +- ...-provide-a-toolbox-bitmap-for-a-control.md | 6 ++-- ...how-to-resize-controls-on-windows-forms.md | 2 +- ...iles-using-the-savefiledialog-component.md | 2 +- ...-set-pictures-at-run-time-windows-forms.md | 3 +- ...-the-run-time-behavior-of-a-usercontrol.md | 3 +- ...a-background-thread-to-search-for-files.md | 6 ++-- ...-the-windows-forms-datagridview-control.md | 8 +++-- ...l-mode-jit-data-loading-in-the-datagrid.md | 8 ++++- .../framework/winforms/controls/index.md | 2 +- ...f-the-timer-component-interval-property.md | 4 ++- .../menustrip-control-windows-forms.md | 8 +++-- ...ethod-implementation-in-custom-controls.md | 4 ++- ...ataset-with-wf-bindingnavigator-control.md | 5 +++- .../controls/overriding-the-onpaint-method.md | 3 +- ...cument-component-overview-windows-forms.md | 2 +- ...ewdialog-control-overview-windows-forms.md | 2 +- .../properties-in-windows-forms-controls.md | 8 +++-- .../controls/property-changed-events.md | 5 ++-- ...ise-change-notifications--bindingsource.md | 5 +++- .../rendering-a-windows-forms-control.md | 7 ++++- ...t-set-intervals-with-wf-timer-component.md | 5 +++- ...esignerserializationvisibilityattribute.md | 6 ++-- ...et-data-with-wf-bindingsource-component.md | 7 +++-- .../winforms/controls/soundplayer-class.md | 6 +++- ...ontainer-control-overview-windows-forms.md | 3 +- .../controls/statusstrip-control-overview.md | 3 +- .../winforms/controls/statusstrip-control.md | 5 +++- .../tablelayoutpanel-control-windows-forms.md | 8 +++-- .../timer-component-overview-windows-forms.md | 4 ++- .../controls/toolstrip-technology-summary.md | 29 +++++++++++++------ .../controls/toolstripcontainer-control.md | 6 +++- .../toolstrippanel-control-overview.md | 3 +- ...hooting-control-and-component-authoring.md | 2 +- .../controls/varieties-of-custom-controls.md | 17 ++++++++--- ...st-in-time-data-loading-in-the-datagrid.md | 6 +++- ...-windows-forms-using-a-tablelayoutpanel.md | 6 ++-- ...ting-the-toolbox-with-custom-components.md | 12 ++++---- ...professionally-styled-toolstrip-control.md | 4 +-- ...ith-menu-merging-and-toolstrip-controls.md | 4 +-- ...a-form-that-uses-a-background-operation.md | 14 ++++----- ...indows-forms-control-with-visual-csharp.md | 2 +- ...-running-an-operation-in-the-background.md | 2 +- ...ting-status-bar-information-at-run-time.md | 3 +- ...-the-windows-forms-datagridview-control.md | 4 +-- .../winforms/controls/webbrowser-security.md | 5 ++-- ...reating-event-handlers-in-windows-forms.md | 6 ++-- ...data-sources-supported-by-windows-forms.md | 4 ++- .../winforms/events-overview-windows-forms.md | 8 +++-- .../high-dpi-support-in-windows-forms.md | 6 ++-- .../winforms/how-keyboard-input-works.md | 14 ++++++--- ...-to-change-the-borders-of-windows-forms.md | 5 ++-- ...d-control-and-format-the-displayed-data.md | 4 +-- ...-simple-bound-control-on-a-windows-form.md | 2 +- ...forms-application-from-the-command-line.md | 2 +- ...-handlers-at-run-time-for-windows-forms.md | 2 +- ...etermine-which-modifier-key-was-pressed.md | 3 +- .../winforms/how-to-resize-windows-forms.md | 2 +- ...e-file-and-data-access-in-windows-forms.md | 16 ++++++---- ...se-input-in-a-windows-forms-application.md | 5 +++- .../security-in-windows-forms-overview.md | 18 ++++++------ .../user-input-validation-in-windows-forms.md | 13 +++++++-- ...indows-forms-accessibility-improvements.md | 4 +-- .../winforms/windows-forms-security.md | 21 ++++++++------ 147 files changed, 557 insertions(+), 305 deletions(-) diff --git a/dotnet-desktop-guide/framework/winforms/additional-security-considerations-in-windows-forms.md b/dotnet-desktop-guide/framework/winforms/additional-security-considerations-in-windows-forms.md index c42cd8c2f9..f6de6ddb32 100644 --- a/dotnet-desktop-guide/framework/winforms/additional-security-considerations-in-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/additional-security-considerations-in-windows-forms.md @@ -9,11 +9,13 @@ helpviewer_keywords: ms.assetid: 15abda8b-0527-47c7-aedb-77ab595f2bf1 --- # Additional Security Considerations in Windows Forms + .NET Framework security settings might cause your application to run differently in a partial trust environment than on your local computer. The .NET Framework restricts access to such critical local resources as the file system, network, and unmanaged APIs, among other things. The security settings affect the ability to call the Microsoft Windows API or other APIs that cannot be verified by the security system. Security also affects other aspects of your application, including file and data access, and printing. For more information about file and data access in a partial trust environment, see [More Secure File and Data Access in Windows Forms](more-secure-file-and-data-access-in-windows-forms.md). For more information about printing in a partial trust environment, see [More Secure Printing in Windows Forms](more-secure-printing-in-windows-forms.md). The following sections discuss how to work with the Clipboard, perform window manipulation, and call the Windows API from applications that are running in a partial trust environment. ## Clipboard Access + The class controls access to the Clipboard, and the associated enumeration value indicates the level of access. The following table shows the possible permission levels. |UIPermissionClipboard value|Description| @@ -22,9 +24,10 @@ ms.assetid: 15abda8b-0527-47c7-aedb-77ab595f2bf1 ||The Clipboard can be used with some restrictions. The ability to put data on the Clipboard (Copy or Cut command operations) is unrestricted. Intrinsic controls that accept paste, such as a text box, can accept Clipboard data, but user controls cannot programmatically read from the Clipboard.| ||The Clipboard cannot be used.| - By default, the Local Intranet zone receives access and the Internet zone receives access. This means that the application can copy data to the Clipboard, but the application cannot programmatically paste to or read from the Clipboard. These restrictions prevent programs without full trust from reading content copied to the Clipboard by another application. If your application requires full Clipboard access but you do not have the permissions, you will have to elevate the permissions for your application. For more information about elevating permissions, see [General Security Policy Administration](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ed5htz45(v=vs.100)). + By default, the Local Intranet zone receives access and the Internet zone receives access. This means that the application can copy data to the Clipboard, but the application cannot programmatically paste to or read from the Clipboard. These restrictions prevent programs without full trust from reading content copied to the Clipboard by another application. If your application requires full Clipboard access but you do not have the permissions, you will have to elevate the permissions for your application. For more information about elevating permissions, see [General Security Policy Administration](/previous-versions/dotnet/netframework-4.0/ed5htz45(v=vs.100)). ## Window Manipulation + The class also controls permission to perform window manipulation and other UI-related actions, and the associated enumeration value indicates the level of access. The following table shows the possible permission levels. By default, the Local Intranet zone receives access and the Internet zone receives access. This means that in the Internet zone, the application can perform most windowing and UI actions, but the window's appearance will be modified. The modified window displays a balloon notification when first run, contains modified title bar text, and requires a close button on the title bar. The balloon notification and the title bar identify to the user of the application that the application is running under partial trust. @@ -59,11 +62,13 @@ ms.assetid: 15abda8b-0527-47c7-aedb-77ab595f2bf1 ||- Calling the method.| ### Hosting Third-Party Controls + Another kind of window manipulation can occur if your forms host third-party controls. A third-party control is any custom that you have not developed and compiled yourself. Although the hosting scenario is hard to exploit, it is theoretically possible for a third-party control to expand its rendering surface to cover the entire area of your form. This control could then mimic a critical dialog box, and request information such as username/password combinations or bank account numbers from your users. To limit this potential risk, use third-party controls only from vendors you can trust. If you use third-party controls you have downloaded from an unverifiable source, we recommend that you review the source code for potential exploits. After you've verified that the source is non-malicious, you should compile the assembly yourself to ensure that the source matches the assembly. ## Windows API Calls + If your application design requires calling a function from the Windows API, you are accessing unmanaged code. In this case the code's actions to the window or operating system cannot be determined when you are working with Windows API calls or values. The class and the value of the enumeration control access to unmanaged code. An application can access unmanaged code only when it is granted the permission. By default, only applications that are running locally can call unmanaged code. Some Windows Forms members provide unmanaged access that requires the permission. The following table lists the members in the namespace that require the permission. For more information about the permissions that are required for a member, see the .NET Framework class library documentation. @@ -80,7 +85,7 @@ ms.assetid: 15abda8b-0527-47c7-aedb-77ab595f2bf1 If your application does not have permission to call unmanaged code, your application must request permission, or you must consider alternative ways of implementing features; in many cases, Windows Forms provides a managed alternative to Windows API functions. If no alternative means exist and the application must access unmanaged code, you will have to elevate the permissions for the application. - Permission to call unmanaged code allows an application to perform most anything. Therefore, permission to call unmanaged code should only be granted for applications that come from a trusted source. Alternatively, depending on the application, the piece of application functionality that makes the call to unmanaged code could be optional, or enabled in the full trust environment only. For more information about dangerous permissions, see [Dangerous Permissions and Policy Administration](https://docs.microsoft.com/dotnet/framework/misc/dangerous-permissions-and-policy-administration). For more information about elevating permissions, see [General Security Policy Administration](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ed5htz45(v=vs.100)). + Permission to call unmanaged code allows an application to perform most anything. Therefore, permission to call unmanaged code should only be granted for applications that come from a trusted source. Alternatively, depending on the application, the piece of application functionality that makes the call to unmanaged code could be optional, or enabled in the full trust environment only. For more information about dangerous permissions, see [Dangerous Permissions and Policy Administration](/dotnet/framework/misc/dangerous-permissions-and-policy-administration). For more information about elevating permissions, see [General Security Policy Administration](/previous-versions/dotnet/netframework-4.0/ed5htz45(v=vs.100)). ## See also diff --git a/dotnet-desktop-guide/framework/winforms/advanced/application-settings-architecture.md b/dotnet-desktop-guide/framework/winforms/advanced/application-settings-architecture.md index 19b2840185..2fef817448 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/application-settings-architecture.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/application-settings-architecture.md @@ -9,6 +9,7 @@ helpviewer_keywords: ms.assetid: c8eb2ad0-fac6-4ea2-9140-675a4a44d562 --- # Application Settings Architecture + This topic describes how the Application Settings architecture works, and explores advanced features of the architecture, such as grouped settings and settings keys. The application settings architecture supports defining strongly typed settings with either application or user scope, and persisting the settings between application sessions. The architecture provides a default persistence engine for saving settings to and loading them from the local file system. The architecture also defines interfaces for supplying a custom persistence engine. @@ -16,6 +17,7 @@ This topic describes how the Application Settings architecture works, and explor Interfaces are provided that enable custom components to persist their own settings when they are hosted in an application. By using settings keys, components can keep settings for multiple instances of the component separate. ## Defining Settings + The application settings architecture is used within both ASP.NET and Windows Forms, and it contains a number of base classes that are shared across both environments. The most important is , which provides access to settings through a collection, and provides low-level methods for loading and saving settings. Each environment implements its own class derived from to provide additional settings functionality for that environment. In a Windows Forms-based application, all application settings must be defined on a class derived from the class, which adds the following functionality to the base class: - Higher-level loading and saving operations @@ -36,6 +38,7 @@ This topic describes how the Application Settings architecture works, and explor [!code-vb[ApplicationSettings.Create#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/ApplicationSettings.Create/VB/MyAppSettings.vb#1)] ## Settings Persistence + The class does not itself persist or load settings; this job falls to the settings provider, a class that derives from . If a derived class of does not specify a settings provider through the , then the default provider, , is used. The configuration system that was originally released with the .NET Framework supports providing static application configuration data through either the local computer's machine.config file or within an `app.`exe.config file that you deploy with your application. The class expands this native support in the following ways: @@ -82,9 +85,10 @@ This topic describes how the Application Settings architecture works, and explor ``` - For a definition of the elements within the application settings section of a configuration file, see [Application Settings Schema](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/application-settings-schema). + For a definition of the elements within the application settings section of a configuration file, see [Application Settings Schema](/dotnet/framework/configure-apps/file-schema/application-settings-schema). ### Settings Bindings + Application settings uses the Windows Forms data binding architecture to provide two-way communication of settings updates between the settings object and components. If you use Visual Studio to create application settings and assign them to component properties, these bindings are generated automatically. You can only bind an application setting to a component that supports the interface. Also, the component must implement a change event for a specific bound property, or notify application settings that the property has changed through the interface. If the component does not implement and you are binding through Visual Studio, the bound properties will be set the first time, but will not update. If the component implements but does not support property change notifications, the binding will not update in the settings file when the property is changed. @@ -92,6 +96,7 @@ This topic describes how the Application Settings architecture works, and explor Some Windows Forms components, such as , do not support settings bindings. ### Settings Serialization + When must save settings to disk, it performs the following actions: 1. Uses reflection to examine all of the properties defined on your derived class, finding those that are applied with either or . @@ -103,6 +108,7 @@ This topic describes how the Application Settings architecture works, and explor If you implement your own settings class, you can use the to mark a setting for either binary or custom serialization using the enumeration. For more information on creating your own settings class in code, see [How to: Create Application Settings](how-to-create-application-settings.md). ### Settings File Locations + The location of the `app`.exe.config and *user*.config files will differ based on how the application is installed. For a Windows Forms-based application copied onto the local computer, `app`.exe.config will reside in the same directory as the base directory of the application's main executable file, and *user*.config will reside in the location specified by the property. For an application installed by means of ClickOnce, both of these files will reside in the ClickOnce Data Directory underneath %InstallRoot%\Documents and Settings\\*username*\Local Settings. The storage location of these files is slightly different if a user has enabled roaming profiles, which enables a user to define different Windows and application settings when they are using other computers within a domain. In that case, both ClickOnce applications and non-ClickOnce applications will have their `app`.exe.config and *user*.config files stored under %InstallRoot%\Documents and Settings\\*username*\Application Data. @@ -110,11 +116,13 @@ This topic describes how the Application Settings architecture works, and explor For more information about how the Application Settings feature works with the new deployment technology, see [ClickOnce and Application Settings](/visualstudio/deployment/clickonce-and-application-settings). For more information about the ClickOnce Data Directory, see [Accessing Local and Remote Data in ClickOnce Applications](/visualstudio/deployment/accessing-local-and-remote-data-in-clickonce-applications). ## Application Settings and Security + Application settings are designed to work in partial trust, a restricted environment that is the default for Windows Forms applications hosted over the Internet or an intranet. No special permissions beyond partial trust are needed to use application settings with the default settings provider. When application settings are used in a ClickOnce application, the `user`.config file is stored in the ClickOnce data directory. The size of the application's `user`.config file cannot exceed the data directory quota set by ClickOnce. For more information, see [ClickOnce and Application Settings](/visualstudio/deployment/clickonce-and-application-settings). ## Custom Settings Providers + In the Application Settings architecture, there is a loose coupling between the applications settings wrapper class, derived from , and the associated settings provider or providers, derived from . This association is defined only by the applied to the wrapper class or its individual properties. If a settings provider is not explicitly specified, the default provider, , is used. As a result, this architecture supports creating and using custom settings providers. For example, suppose that you want to develop and use `SqlSettingsProvider`, a provider that will store all settings data in a Microsoft SQL Server database. Your -derived class would receive this information in its `Initialize` method as a parameter of type . You would then implement the method to retrieve your settings from the data store, and to save them. Your provider can use the supplied to to determine the property's name, type, and scope, as well as any other settings attributes defined for that property. @@ -148,4 +156,4 @@ This topic describes how the Application Settings architecture works, and explor - [Application Settings Overview](application-settings-overview.md) - [Application Settings for Custom Controls](application-settings-for-custom-controls.md) - [ClickOnce and Application Settings](/visualstudio/deployment/clickonce-and-application-settings) -- [Application Settings Schema](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/application-settings-schema) +- [Application Settings Schema](/dotnet/framework/configure-apps/file-schema/application-settings-schema) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/application-settings-for-windows-forms.md b/dotnet-desktop-guide/framework/winforms/advanced/application-settings-for-windows-forms.md index a806db7b36..592b35e03d 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/application-settings-for-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/application-settings-for-windows-forms.md @@ -9,9 +9,11 @@ helpviewer_keywords: ms.assetid: 64090a34-8556-4904-8ea0-20efe9f8c886 --- # Application Settings for Windows Forms + The Applications Settings feature of Windows Forms makes it easy to create, store, and maintain custom application and user preferences on the client. With Application Settings, you can store not only application data such as database connection strings, but also user-specific data, such as toolbar positions and most-recently used lists. ## In This Section + [Application Settings Overview](application-settings-overview.md) Discusses how to create and store settings data on behalf of your application and your users. @@ -32,7 +34,7 @@ The Applications Settings feature of Windows Forms makes it easy to create, stor ## Related topics -[Windows Forms Configuration Section](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/winforms/index) +[Windows Forms Configuration Section](/dotnet/framework/configure-apps/file-schema/winforms/index) Documents the settings to enable High DPI support in Windows Forms Application starting with the .NET Framework 4.7. ## See also diff --git a/dotnet-desktop-guide/framework/winforms/advanced/application-settings-overview.md b/dotnet-desktop-guide/framework/winforms/advanced/application-settings-overview.md index c1d2378801..c17df0399c 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/application-settings-overview.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/application-settings-overview.md @@ -18,7 +18,8 @@ This article discusses how to create and store settings data on behalf of your a Application settings enables developers to save state in their application using very little custom code, and is a replacement for dynamic properties in previous versions of the .NET Framework. Application settings contains many improvements over dynamic properties, which are read-only, late-bound, and require more custom programming. The dynamic property classes have been retained in .NET Framework 2.0, but they are just shell classes that thinly wrap the application settings classes. -## What Are Application Settings? +## What Are Application Settings + Your Windows Forms applications will often require data that's critical to running the application, but which you don't want to include directly in the application's code. If your application uses a Web Service or a database server, you may want to store this information in a separate file, so that you can change it in the future without recompiling. Similarly, your applications may require storing data that is specific to the current user. Most applications, for example, have user preferences that customize the application's appearance and behavior. Application settings addresses both needs by providing an easy way to store both application-scoped and user-scoped settings on the client computer. Using Visual Studio or a code editor, you define a setting for a given property by specifying its name, data type, and scope (application or user). You can even place related settings into named groups for easier use and readability. Once defined, these settings are persisted and read back into memory automatically at run time. A pluggable architecture enables the persistence mechanism to be changed, but by default, the local file system is used. @@ -30,13 +31,15 @@ This article discusses how to create and store settings data on behalf of your a Custom controls can also save their own settings by implementing the interface, which exposes the method. The Windows Forms control implements this interface to save the position of toolbars and toolbar items between application sessions. For more information about custom controls and application settings, see [Application Settings for Custom Controls](application-settings-for-custom-controls.md). ## Limitations of Application Settings + You cannot use application settings in an unmanaged application that hosts the .NET Framework. Settings will not work in such environments as Visual Studio add-ins, C++ for Microsoft Office, control hosting in Internet Explorer, or Microsoft Outlook add-ins and projects. You currently cannot bind to some properties in Windows Forms. The most notable example is the property, as binding to this property would cause unpredictable behavior at run time. You can usually work around these issues by saving and loading these settings programmatically. - Application settings has no built-in facility for encrypting information automatically. You should never store security-related information, such as database passwords, in clear text. If you want to store such sensitive information, you as the application developer are responsible for making sure it is secure. If you want to store connection strings, we recommend that you use Windows Integrated Security and not resort to hard-coding passwords into the URL. For more information, see [Code Access Security and ADO.NET](https://docs.microsoft.com/dotnet/framework/data/adonet/code-access-security). + Application settings has no built-in facility for encrypting information automatically. You should never store security-related information, such as database passwords, in clear text. If you want to store such sensitive information, you as the application developer are responsible for making sure it is secure. If you want to store connection strings, we recommend that you use Windows Integrated Security and not resort to hard-coding passwords into the URL. For more information, see [Code Access Security and ADO.NET](/dotnet/framework/data/adonet/code-access-security). ## Getting Started with Application Settings + If you use Visual Studio, you can define settings within the Windows Forms Designer using the **(ApplicationSettings)** property in the **Properties** window. When you define settings this way, Visual Studio automatically creates a custom managed wrapper class that associates each setting with a class property. Visual Studio also takes care of binding the setting to a property on a form or control so that the control's settings are restored automatically when its form is displayed, and saved automatically when the form is closed. If you want more detailed control over your settings, you can define your own custom applications settings wrapper class. This is accomplished by deriving a class from , adding a property that corresponds to each setting, and applying special attributes to these properties. For details about creating wrapper classes, see [Application Settings Architecture](application-settings-architecture.md). diff --git a/dotnet-desktop-guide/framework/winforms/advanced/bi-directional-support-for-windows-forms-applications.md b/dotnet-desktop-guide/framework/winforms/advanced/bi-directional-support-for-windows-forms-applications.md index 7f233250d5..7cf8c3e8cd 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/bi-directional-support-for-windows-forms-applications.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/bi-directional-support-for-windows-forms-applications.md @@ -9,13 +9,16 @@ helpviewer_keywords: - "Windows Forms, bi-directional support" --- # Bi-Directional Support for Windows Forms Applications + You can use Visual Studio to create Windows-based applications that support bi-directional (right-to-left) languages such as Arabic and Hebrew. This includes standard forms, dialog boxes, MDI forms, and all the controls you can work with in these forms—that is, all the objects in the namespace. ## Culture Support + Culture and UI culture settings determine how an application works with dates, times, currency, and other information. Support for culture and UI culture is the same for bi-directional languages as it is for any other languages. For more information, see [Culture-specific classes for global Windows forms and web forms](/visualstudio/ide/globalizing-and-localizing-applications). ## RightToLeft and RightToLeftLayout Properties - The base class, from which forms derive, includes a property that you can set to change the reading order of a form and its controls. If you set the form's property, by default controls on the form inherit this setting. However, you can also set the property individually on most controls. Also see [How to: Display Right-to-Left Text in Windows Forms for Globalization](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/7d3337xw(v=vs.100)). + + The base class, from which forms derive, includes a property that you can set to change the reading order of a form and its controls. If you set the form's property, by default controls on the form inherit this setting. However, you can also set the property individually on most controls. Also see [How to: Display Right-to-Left Text in Windows Forms for Globalization](/previous-versions/visualstudio/visual-studio-2010/7d3337xw(v=vs.100)). The effect of the property can differ from one control to another. In some controls the property only sets the reading order, as in the , and controls. In other controls, the property changes both reading order and layout. This includes the , and controls. Other controls require that the property be applied to mirror its layout from right to left. The following table provides details on how the and properties affect individual Windows Forms controls. @@ -71,22 +74,27 @@ You can use Visual Studio to create Windows-based applications that support bi-d ||Displayed on the left side instead of right side of scrollable controls|No effect|No| ## Encoding + Windows Forms support Unicode, so you can include any character set when you create your bi-directional applications. However, not all Windows Forms controls support Unicode on all platforms. ## GDI+ + You can use GDI+ to draw text with right-to-left reading order. The method, which is used to draw text, supports a `StringFormat` parameter that you can set to the member of the enumeration in order to reverse the point of origin for the text. ## Common Dialog Boxes + System tools such as the File Open dialog box are under the control of Windows. They inherit language elements from the operating system. If you are using a version of Windows with the correct language settings, these dialog boxes will work correctly with bi-directional languages. Similarly, message boxes go through the operating system and support bi-directional text. The captions on message box buttons are based on the current language setting. By default, message boxes do not use right-to-left reading order, but you can specify a parameter to change the reading order when the message boxes are displayed. ## RightToLeft, Scrollbars, and ScrollableControl + There is currently a limitation in Windows Forms that prevents all classes derived from from acting properly when both is enabled and is set to . For example, let's say that you place a control such as —or a container class derived from (such as or )—on your form. If you set on the container to and then set the property on one or more of the controls inside of the container to , then no scrollbar ever appears. The class derived from acts as if were set to . Currently, the only workaround is to nest the inside another . For instance, if you need to work in this situation, you can place it inside of a control and set on the to . ## Mirroring + *Mirroring* refers to reversing the layout of UI elements so that they flow from right to left. In a mirrored Windows Form, for example, the Minimize, Maximize, and Close buttons appear left-most on the title bar, not right-most. Setting a form or control's property to `true` reverses the reading order of elements on a form, but this setting does not reverse the layout to be right-to-left— that is, it does not cause mirroring. For example, setting this property does not move the **Minimize**, **Maximize**, and **Close** buttons in the form's title bar to the left side of the form. Similarly, some controls, such as the control, require mirroring in order to change their display to be appropriate for Arabic or Hebrew. You can mirror these controls by settings the property. @@ -111,4 +119,4 @@ You can use Visual Studio to create Windows-based applications that support bi-d ## See also -- [Bidirectional Support for ASP.NET Web Applications](https://docs.microsoft.com/previous-versions/aspnet/6eedwbtt(v=vs.100)) +- [Bidirectional Support for ASP.NET Web Applications](/previous-versions/aspnet/6eedwbtt(v=vs.100)) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/com-interop-by-displaying-a-windows-form-shadow.md b/dotnet-desktop-guide/framework/winforms/advanced/com-interop-by-displaying-a-windows-form-shadow.md index 527c995b1b..19ce1f7eb9 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/com-interop-by-displaying-a-windows-form-shadow.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/com-interop-by-displaying-a-windows-form-shadow.md @@ -10,6 +10,7 @@ helpviewer_keywords: ms.assetid: 87aac8ad-3c04-43b3-9b0c-d0b00df9ee74 --- # How to: Support COM Interop by Displaying a Windows Form with the ShowDialog Method + You can resolve Component Object Model (COM) interoperability problems by displaying your Windows Form on a .NET Framework message loop, which is created by using the method. To make a form work correctly from a COM client application, you must run it on a Windows Forms message loop. To do this, use one of the following approaches: @@ -19,6 +20,7 @@ You can resolve Component Object Model (COM) interoperability problems by displa - Display each Windows Form on a separate thread. For more information, see [How to: Support COM Interop by Displaying Each Windows Form on Its Own Thread](how-to-support-com-interop-by-displaying-each-windows-form-on-its-own-thread.md). ## Procedure + Using the method can be the easiest way to display a form on a .NET Framework message loop because, of all the approaches, it requires the least code to implement. The method suspends the unmanaged application's message loop and displays the form as a dialog box. Because the host application's message loop has been suspended, the method creates a new .NET Framework message loop to process the form's messages. @@ -33,6 +35,6 @@ You can resolve Component Object Model (COM) interoperability problems by displa ## See also -- [Exposing .NET Framework Components to COM](https://docs.microsoft.com/dotnet/framework/interop/exposing-dotnet-components-to-co) +- [Exposing .NET Framework Components to COM](/dotnet/framework/interop/exposing-dotnet-components-to-co) - [How to: Support COM Interop by Displaying Each Windows Form on Its Own Thread](how-to-support-com-interop-by-displaying-each-windows-form-on-its-own-thread.md) - [Windows Forms and Unmanaged Applications](windows-forms-and-unmanaged-applications.md) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/effects-of-modifying-base-form-appearance.md b/dotnet-desktop-guide/framework/winforms/advanced/effects-of-modifying-base-form-appearance.md index 227655bb3d..d17ea5427f 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/effects-of-modifying-base-form-appearance.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/effects-of-modifying-base-form-appearance.md @@ -19,6 +19,6 @@ Modifications made to the base form at run time have no affect on inherited form ## See also -- [base](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/base) +- [base](/dotnet/csharp/language-reference/keywords/base) - [How to: Inherit Windows Forms](how-to-inherit-windows-forms.md) - [Windows Forms Visual Inheritance](windows-forms-visual-inheritance.md) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/globalizing-windows-forms.md b/dotnet-desktop-guide/framework/winforms/advanced/globalizing-windows-forms.md index 95edbcb6a1..5c005eb940 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/globalizing-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/globalizing-windows-forms.md @@ -27,7 +27,7 @@ Introduces the `ImeMode` property, which is used to control the type of input a ## Related sections -- [Globalizing and localizing .NET applications](https://docs.microsoft.com/dotnet/standard/globalization-localization/index) +- [Globalizing and localizing .NET applications](/dotnet/standard/globalization-localization/index) - [Walkthrough: Downloading Satellite Assemblies on Demand with the ClickOnce Deployment API Using the Designer](/visualstudio/deployment/walkthrough-downloading-satellite-assemblies-on-demand-with-the-clickonce-deployment-api-using-the-designer) @@ -35,12 +35,12 @@ Introduces the `ImeMode` property, which is used to control the type of input a - [Walkthrough: Downloading Satellite Assemblies on Demand with the ClickOnce Deployment API](/visualstudio/deployment/walkthrough-downloading-satellite-assemblies-on-demand-with-the-clickonce-deployment-api) -- [How to: Set the Culture and UI Culture for Windows Forms Globalization](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/b28bx3bh(v=vs.100)) +- [How to: Set the Culture and UI Culture for Windows Forms Globalization](/previous-versions/visualstudio/visual-studio-2010/b28bx3bh(v=vs.100)) -- [How to: Create Mirrored Windows Forms and Controls](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/xwbz5ws0(v=vs.100)) +- [How to: Create Mirrored Windows Forms and Controls](/previous-versions/visualstudio/visual-studio-2010/xwbz5ws0(v=vs.100)) -- [How to: Support Localization on Windows Forms Using AutoSize and the TableLayoutPanel Control](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/1zkt8b33(v=vs.100)) +- [How to: Support Localization on Windows Forms Using AutoSize and the TableLayoutPanel Control](/previous-versions/visualstudio/visual-studio-2010/1zkt8b33(v=vs.100)) -- [Walkthrough: Localizing Windows Forms](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/y99d1cd3(v=vs.100)) +- [Walkthrough: Localizing Windows Forms](/previous-versions/visualstudio/visual-studio-2010/y99d1cd3(v=vs.100)) -- [Walkthrough: Creating a Layout That Adjusts Proportion for Localization](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100)) +- [Walkthrough: Creating a Layout That Adjusts Proportion for Localization](/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100)) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/how-to-copy-and-paste-an-elementhost-control-at-design-time.md b/dotnet-desktop-guide/framework/winforms/advanced/how-to-copy-and-paste-an-elementhost-control-at-design-time.md index 69e34d46d0..f3030dbe11 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/how-to-copy-and-paste-an-elementhost-control-at-design-time.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/how-to-copy-and-paste-an-elementhost-control-at-design-time.md @@ -39,6 +39,6 @@ This procedure shows you how to copy a Windows Presentation Foundation (WPF) con - - -- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability) +- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability) - [Using WPF Controls](using-wpf-controls.md) - [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/how-to-create-application-settings.md b/dotnet-desktop-guide/framework/winforms/advanced/how-to-create-application-settings.md index 0797febb44..c0654569f1 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/how-to-create-application-settings.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/how-to-create-application-settings.md @@ -10,11 +10,12 @@ helpviewer_keywords: ms.assetid: 1e7aa347-af75-41e5-89ca-f53cab704f72 --- # How to: Create Application Settings + Using managed code, you can create new application settings and bind them to properties on your form or your form's controls, so that these settings are loaded and saved automatically at run time. In the following procedure, you manually create a wrapper class that derives from . To this class you add a publicly accessible property for each application setting that you want to expose. - You can also perform this procedure using minimal code in the Visual Studio designer. Also see [How to: Create Application Settings Using the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/wabtadw6(v=vs.100)). + You can also perform this procedure using minimal code in the Visual Studio designer. Also see [How to: Create Application Settings Using the Designer](/previous-versions/visualstudio/visual-studio-2010/wabtadw6(v=vs.100)). ### To create new Application Settings programmatically @@ -38,6 +39,7 @@ Using managed code, you can create new application settings and bind them to pro You have now successfully created a new application setting and bound it to the specified property. ## .NET Framework Security + The default settings provider, , persists information to configuration files as plain text. This limits security to the file access security provided by the operating system for the current user. Because of this, care must be taken with the information stored in configuration files. For example, one common use for application settings is to store connection strings that point to the application's data store. However, because of security concerns, such strings should not include passwords. For more information about connection strings, see . ## See also diff --git a/dotnet-desktop-guide/framework/winforms/advanced/how-to-inherit-forms-using-the-inheritance-picker-dialog-box.md b/dotnet-desktop-guide/framework/winforms/advanced/how-to-inherit-forms-using-the-inheritance-picker-dialog-box.md index 0ab2f81ece..74ac1baab7 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/how-to-inherit-forms-using-the-inheritance-picker-dialog-box.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/how-to-inherit-forms-using-the-inheritance-picker-dialog-box.md @@ -51,7 +51,7 @@ The easiest way to inherit a form or other object is to use the **Inheritance Pi ## See also -- [Inherits Statement](https://docs.microsoft.com/dotnet/visual-basic/language-reference/statements/inherits-statement) -- [using](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/using) +- [Inherits Statement](/dotnet/visual-basic/language-reference/statements/inherits-statement) +- [using](/dotnet/csharp/language-reference/keywords/using) - [Effects of Modifying a Base Form's Appearance](effects-of-modifying-base-form-appearance.md) - [Windows Forms Visual Inheritance](windows-forms-visual-inheritance.md) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/how-to-inherit-windows-forms.md b/dotnet-desktop-guide/framework/winforms/advanced/how-to-inherit-windows-forms.md index d618554754..dec464e8b1 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/how-to-inherit-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/how-to-inherit-windows-forms.md @@ -34,12 +34,12 @@ For more information about inheriting forms at design time using the **Inheritan public class Form2 : Namespace1.Form1 ``` - When inheriting forms, keep in mind that issues may arise with regard to event handlers being called twice, because each event is being handled by both the base class and the inherited class. For more information on how to avoid this problem, see [Troubleshooting Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers). + When inheriting forms, keep in mind that issues may arise with regard to event handlers being called twice, because each event is being handled by both the base class and the inherited class. For more information on how to avoid this problem, see [Troubleshooting Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers). ## See also -- [Inherits Statement](https://docs.microsoft.com/dotnet/visual-basic/language-reference/statements/inherits-statement) -- [Imports Statement (.NET Namespace and Type)](https://docs.microsoft.com/dotnet/visual-basic/language-reference/statements/imports-statement-net-namespace-and-type) -- [using](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/using) +- [Inherits Statement](/dotnet/visual-basic/language-reference/statements/inherits-statement) +- [Imports Statement (.NET Namespace and Type)](/dotnet/visual-basic/language-reference/statements/imports-statement-net-namespace-and-type) +- [using](/dotnet/csharp/language-reference/keywords/using) - [Effects of Modifying a Base Form's Appearance](effects-of-modifying-base-form-appearance.md) - [Windows Forms Visual Inheritance](windows-forms-visual-inheritance.md) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/how-to-print-a-multi-page-text-file-in-windows-forms.md b/dotnet-desktop-guide/framework/winforms/advanced/how-to-print-a-multi-page-text-file-in-windows-forms.md index 4c97493017..9967e8087e 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/how-to-print-a-multi-page-text-file-in-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/how-to-print-a-multi-page-text-file-in-windows-forms.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: 362427f8-03d4-4826-b49f-60ab066ad322 --- # How to: Print a Multi-Page Text File in Windows Forms + It is very common for Windows-based applications to print text. The class provides methods for drawing objects (graphics or text) to a device, such as a screen or printer. > [!NOTE] @@ -42,17 +43,19 @@ It is very common for Windows-based applications to print text. The The root namespace for classes in the .NET Framework that handle network connectivity. @@ -23,7 +25,8 @@ The .NET Framework provides classes for displaying Web pages, downloading Web co A managed wrapper class for the `WebBrowser` control that is included with Windows. ## Related Sections - [Network Programming in the .NET Framework](https://docs.microsoft.com/dotnet/framework/network-programming/index) + + [Network Programming in the .NET Framework](/dotnet/framework/network-programming/index) An introduction to networking in the .NET Framework. [Windows Forms Data Binding](../windows-forms-data-binding.md) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/using-wpf-controls.md b/dotnet-desktop-guide/framework/winforms/advanced/using-wpf-controls.md index 6e61f8f430..f3ed06f2e2 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/using-wpf-controls.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/using-wpf-controls.md @@ -19,4 +19,4 @@ You can also use Windows Forms controls in WPF-based applications. For more info ## See also -- [WPF and Windows Forms interoperation](https://docs.microsoft.com/dotnet/framework/wpf/advanced/wpf-and-windows-forms-interoperation) +- [WPF and Windows Forms interoperation](/dotnet/framework/wpf/advanced/wpf-and-windows-forms-interoperation) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-arranging-wpf-content-on-windows-forms-at-design-time.md b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-arranging-wpf-content-on-windows-forms-at-design-time.md index 2b57c4c5e5..19fa40ba36 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-arranging-wpf-content-on-windows-forms-at-design-time.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-arranging-wpf-content-on-windows-forms-at-design-time.md @@ -130,6 +130,6 @@ A WPF control hosted on a form has the same anchoring and docking behavior as ot - [How to: Anchor and Dock Child Controls in a TableLayoutPanel Control](../controls/how-to-anchor-and-dock-child-controls-in-a-tablelayoutpanel-control.md) - [How to: Align a Control to the Edges of Forms at Design Time](../controls/how-to-align-a-control-to-the-edges-of-forms-at-design-time.md) - [Walkthrough: Arranging Controls on Windows Forms Using Snaplines](../controls/walkthrough-arranging-controls-on-windows-forms-using-snaplines.md) -- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability) +- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability) - [Using WPF Controls](using-wpf-controls.md) - [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-assigning-wpf-content-on-windows-forms-at-design-time.md b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-assigning-wpf-content-on-windows-forms-at-design-time.md index 599c379fda..92bfb46a48 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-assigning-wpf-content-on-windows-forms-at-design-time.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-assigning-wpf-content-on-windows-forms-at-design-time.md @@ -83,6 +83,6 @@ You can assign different WPF content to an - -- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability) +- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability) - [Using WPF Controls](using-wpf-controls.md) - [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-creating-an-accessible-windows-based-application.md b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-creating-an-accessible-windows-based-application.md index d373721908..6a7554d8d8 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-creating-an-accessible-windows-based-application.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-creating-an-accessible-windows-based-application.md @@ -28,7 +28,7 @@ This walkthrough will address the five accessibility requirements for the Certif For more information, see [Resources for Designing Accessible Applications](/visualstudio/ide/reference/resources-for-designing-accessible-applications). -For information on supporting varying keyboard layouts, see [Best Practices for Developing World-Ready Applications](https://docs.microsoft.com/dotnet/standard/globalization-localization/best-practices-for-developing-world-ready-apps). +For information on supporting varying keyboard layouts, see [Best Practices for Developing World-Ready Applications](/dotnet/standard/globalization-localization/best-practices-for-developing-world-ready-apps). ## Creating the Project @@ -285,7 +285,7 @@ In this application, no information is conveyed by sound alone. If you use sound #### To supply information by some other means than sound -1. Make the title bar flash by using the Windows API function FlashWindow. For an example of how to call Windows API functions, see [Walkthrough: Calling Windows APIs](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/com-interop/walkthrough-calling-windows-apis). +1. Make the title bar flash by using the Windows API function FlashWindow. For an example of how to call Windows API functions, see [Walkthrough: Calling Windows APIs](/dotnet/visual-basic/programming-guide/com-interop/walkthrough-calling-windows-apis). > [!NOTE] > The user may have the Windows SoundSentry service enabled, which will also cause the window to flash when the system sounds are played through the computer's built-in speaker. diff --git a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-creating-new-wpf-content-on-windows-forms-at-design-time.md b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-creating-new-wpf-content-on-windows-forms-at-design-time.md index 38f6d2a9bb..f100c71d55 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-creating-new-wpf-content-on-windows-forms-at-design-time.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-creating-new-wpf-content-on-windows-forms-at-design-time.md @@ -90,9 +90,9 @@ To add a WPF control to a Windows Form: Windows Forms and WPF are different technologies, but they are designed to interoperate closely. To provide richer appearance and behavior in your applications, try the following: -- Host a Windows Forms control in a WPF page. For more information, see [Walkthrough: Hosting a Windows Forms Control in WPF](https://docs.microsoft.com/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf). +- Host a Windows Forms control in a WPF page. For more information, see [Walkthrough: Hosting a Windows Forms Control in WPF](/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf). -- Apply Windows Forms visual styles to your WPF content. For more information, see [How to: Enable Visual Styles in a Hybrid Application](https://docs.microsoft.com/dotnet/framework/wpf/advanced/how-to-enable-visual-styles-in-a-hybrid-application). +- Apply Windows Forms visual styles to your WPF content. For more information, see [How to: Enable Visual Styles in a Hybrid Application](/dotnet/framework/wpf/advanced/how-to-enable-visual-styles-in-a-hybrid-application). - Change the style of your WPF content. For more information, see [Walkthrough: Styling WPF Content](walkthrough-styling-wpf-content.md). @@ -100,6 +100,6 @@ Windows Forms and WPF are different technologies, but they are designed to inter - - -- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability) +- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability) - [Using WPF Controls](using-wpf-controls.md) - [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-styling-wpf-content.md b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-styling-wpf-content.md index f25c56f697..70c85e9db3 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-styling-wpf-content.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/walkthrough-styling-wpf-content.md @@ -55,7 +55,7 @@ You can apply different styling to a WPF control to change its appearance and be `UserControl1` opens in the WPF Designer. -1. In XAML view, insert the following XAML after the `` opening tag. This XAML creates a gradient with a contrasting gradient border. When the control is clicked, the gradients are changed to generate a pressed button look. For more information, see [Styling and Templating](https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/styles-templates-overview). +1. In XAML view, insert the following XAML after the `` opening tag. This XAML creates a gradient with a contrasting gradient border. When the control is clicked, the gradients are changed to generate a pressed button look. For more information, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview). ```xaml @@ -132,8 +132,8 @@ You can apply different styling to a WPF control to change its appearance and be - - -- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability) +- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability) - [Using WPF Controls](using-wpf-controls.md) - [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio) -- [XAML Overview (WPF)](https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/xaml) -- [Styling and Templating](https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/styles-templates-overview) +- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml) +- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-and-unmanaged-applications-overview.md b/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-and-unmanaged-applications-overview.md index 462c2fe10c..667bfcd8da 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-and-unmanaged-applications-overview.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-and-unmanaged-applications-overview.md @@ -10,14 +10,16 @@ helpviewer_keywords: ms.assetid: 0a26d99d-8135-4895-8760-c9a2b5f67f14 --- # Windows Forms and Unmanaged Applications Overview + Windows Forms applications and controls can interoperate with unmanaged applications, with some caveats. The following sections describe the scenarios and configurations that Windows Forms applications and controls support and those that they do not support. ## Windows Forms Controls and ActiveX Applications + With the exception of Microsoft Internet Explorer and Microsoft Foundation Classes (MFC), Windows Forms controls are not supported in applications designed to host ActiveX controls. Other applications and development tools that are capable of hosting ActiveX controls, including the ActiveX test containers from versions of Visual Studio that are earlier than Visual Studio .NET 2003, are not supported hosts for Windows Forms controls. These constraints also apply to the use of Windows Forms controls through Component Object Model COM interop. The use of a Windows Forms control through a COM callable wrapper (CCW) is supported only in Internet Explorer. For more information about COM interop, see - [COM Interop](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/com-interop/index). + [COM Interop](/dotnet/visual-basic/programming-guide/com-interop/index). The following table shows the available ActiveX hosting support for Windows Forms controls. @@ -27,6 +29,7 @@ Windows Forms applications and controls can interoperate with unmanaged applicat |.NET Framework version 1.1 and later|Internet Explorer 5.01 and later versions

Microsoft Foundation Classes (MFC) 7.0 and later| ## Hosting Windows Forms components as ActiveX controls + In the .NET Framework 1.1, support was extended to include MFC 7.0 and later versions. This support includes any container that is fully compatible with the MFC 7.0 and later ActiveX control container. However, registration of Windows Forms controls as ActiveX controls is not supported. Also, calling the `com.ms.win32.Ole32.CoCreateInstance` method for Windows Forms controls is not supported. Only managed activation of Windows Forms controls is supported. Once you create a Windows Forms control, you can host it in an MFC application just as with an ActiveX control. @@ -34,6 +37,7 @@ Windows Forms applications and controls can interoperate with unmanaged applicat To use Windows Forms controls in your unmanaged application, you must either host the CLR using the unmanaged CLR hosting APIs or use the C++ interop features. Using the C++ interop features is the recommended solution. ## Windows Forms in COM client applications + When you open a Windows Form from a COM client application, such as a Visual Basic 6.0 application or an MFC application, the form may behave unexpectedly. For example, when you press the TAB key, the focus does not change from one control to another control. When you press the ENTER key while a command button has focus, the button's event is not raised. You may also experience unexpected behavior for keystrokes or mouse activity. This behavior occurs because the unmanaged application does not implement the message loop support that Windows Forms requires to work correctly. The message loop provided by the COM client application is fundamentally different from the Windows Forms message loop. @@ -41,6 +45,7 @@ Windows Forms applications and controls can interoperate with unmanaged applicat An application's message loop is an internal program loop that retrieves messages from a thread's message queue, translates them, and then sends them to the application to be handled. The message loop for a Windows Form does not have the same architecture as message loops that earlier applications, such as Visual Basic 6.0 applications and MFC applications, provide. The window messages that are posted to the message loop may be handled differently than the Windows Form expects. Therefore, unexpected behavior may occur. Some keystroke combinations may not work, some mouse activity may not work, or some events may not be raised as expected. ## Resolving Interoperability Issues + You can resolve these problems by displaying the form on a .NET Framework message loop, which is created by using the method. To make a Windows Form work correctly from a COM client application, you must run it on a Windows Forms message loop. To do this, use one of the following approaches: @@ -52,12 +57,12 @@ Windows Forms applications and controls can interoperate with unmanaged applicat ## See also - [Windows Forms and Unmanaged Applications](windows-forms-and-unmanaged-applications.md) -- [COM Interop](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/com-interop/index) -- [COM Interoperability in .NET Framework Applications](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/com-interop/com-interoperability-in-net-framework-applications) -- [COM Interoperability Samples](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2008/cxcz83xf(v=vs.90)) -- [Aximp.exe (Windows Forms ActiveX Control Importer)](https://docs.microsoft.com/dotnet/framework/tools/aximp-exe-windows-forms-activex-control-importer) -- [Exposing .NET Framework Components to COM](https://docs.microsoft.com/dotnet/framework/interop/exposing-dotnet-components-to-co) -- [Packaging an Assembly for COM](https://docs.microsoft.com/dotnet/framework/interop/packaging-an-assembly-for-co) -- [Registering Assemblies with COM](https://docs.microsoft.com/dotnet/framework/interop/registering-assemblies-with-co) +- [COM Interop](/dotnet/visual-basic/programming-guide/com-interop/index) +- [COM Interoperability in .NET Framework Applications](/dotnet/visual-basic/programming-guide/com-interop/com-interoperability-in-net-framework-applications) +- [COM Interoperability Samples](/previous-versions/visualstudio/visual-studio-2008/cxcz83xf(v=vs.90)) +- [Aximp.exe (Windows Forms ActiveX Control Importer)](/dotnet/framework/tools/aximp-exe-windows-forms-activex-control-importer) +- [Exposing .NET Framework Components to COM](/dotnet/framework/interop/exposing-dotnet-components-to-co) +- [Packaging an Assembly for COM](/dotnet/framework/interop/packaging-an-assembly-for-co) +- [Registering Assemblies with COM](/dotnet/framework/interop/registering-assemblies-with-co) - [How to: Support COM Interop by Displaying a Windows Form with the ShowDialog Method](com-interop-by-displaying-a-windows-form-shadow.md) - [How to: Support COM Interop by Displaying Each Windows Form on Its Own Thread](how-to-support-com-interop-by-displaying-each-windows-form-on-its-own-thread.md) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-and-unmanaged-applications.md b/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-and-unmanaged-applications.md index 583e34fe98..98d40917cd 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-and-unmanaged-applications.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-and-unmanaged-applications.md @@ -10,9 +10,11 @@ helpviewer_keywords: ms.assetid: 81bc100c-fa49-4614-85a6-0f7ab59eac8a --- # Windows Forms and Unmanaged Applications + Windows Forms applications and controls can interoperate with unmanaged applications, with some caveats. The following sections describe the scenarios and configurations that Windows Forms applications and controls support and those that they do not support. ## In This Section + [Windows Forms and Unmanaged Applications Overview](windows-forms-and-unmanaged-applications-overview.md) Offers general information about how to use and implement Windows Forms controls that work with unmanaged applications. @@ -22,9 +24,10 @@ Windows Forms applications and controls can interoperate with unmanaged applicat [How to: Support COM Interop by Displaying Each Windows Form on Its Own Thread](how-to-support-com-interop-by-displaying-each-windows-form-on-its-own-thread.md) Provides a code example that shows how to run a Windows Form on its own thread. - Also see [Walkthrough: Supporting COM Interop by Displaying Each Windows Form on Its Own Thread](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233639(v=vs.100)). + Also see [Walkthrough: Supporting COM Interop by Displaying Each Windows Form on Its Own Thread](/previous-versions/visualstudio/visual-studio-2010/ms233639(v=vs.100)). ## Reference + Used to create a separate thread for a Windows Form. @@ -35,5 +38,6 @@ Windows Forms applications and controls can interoperate with unmanaged applicat Marshals calls from an unmanaged application to a form. ## Related Sections - [Exposing .NET Framework Components to COM](https://docs.microsoft.com/dotnet/framework/interop/exposing-dotnet-components-to-co) + + [Exposing .NET Framework Components to COM](/dotnet/framework/interop/exposing-dotnet-components-to-co) Offers general information about how to use .NET Framework types in unmanaged applications. diff --git a/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-visual-inheritance.md b/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-visual-inheritance.md index 0cb8779ba8..d75bfd36be 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-visual-inheritance.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/windows-forms-visual-inheritance.md @@ -12,11 +12,13 @@ helpviewer_keywords: ms.assetid: 857eb737-3602-4d49-bd8b-f70d33ace345 --- # Windows Forms Visual Inheritance + Occasionally, you may decide that a project calls for a form similar to one that you have created in a previous project. Or, you may want to create a basic form with settings such as a watermark or certain control layout that you will then use again within a project, with each iteration containing modifications to the original form template. Form inheritance enables you to create a base form and then inherit from it and make modifications while preserving whatever original settings you need. You can create derived-class forms programmatically or by using the Visual Inheritance picker. ## In This Section + [How to: Inherit Windows Forms](how-to-inherit-windows-forms.md) Gives directions for creating inherited forms in code. @@ -33,11 +35,12 @@ Occasionally, you may decide that a project calls for a form similar to one that Gives directions for using the `GenerateMember` and `Modifiers` properties, which are relevant when the Windows Forms Designer generates a member variable for a component. ## Related Sections - [Inheritance basics (Visual Basic)](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/inheritance-basics) + + [Inheritance basics (Visual Basic)](/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/inheritance-basics) Describes how to define Visual Basic classes that serve as the basis for other classes. - [class](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/class) + [class](/dotnet/csharp/language-reference/keywords/class) Describes the C# approach of classes, in which single inheritance is allowed. - [Troubleshooting Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) + [Troubleshooting Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) Lists common issues that arise with event handlers in inherited components diff --git a/dotnet-desktop-guide/framework/winforms/controls/add-custom-information-to-a-treeview-or-listview-control-wf.md b/dotnet-desktop-guide/framework/winforms/controls/add-custom-information-to-a-treeview-or-listview-control-wf.md index 43fc096969..69deaeb6c8 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/add-custom-information-to-a-treeview-or-listview-control-wf.md +++ b/dotnet-desktop-guide/framework/winforms/controls/add-custom-information-to-a-treeview-or-listview-control-wf.md @@ -15,6 +15,7 @@ helpviewer_keywords: ms.assetid: 68be11de-1d5b-430e-901f-cfbe48d14b19 --- # How to: Add Custom Information to a TreeView or ListView Control (Windows Forms) + You can create a derived node in a Windows Forms control or a derived item in a control. Derivation allows you to add any fields you require, as well as custom methods and constructors for handling them. One use of this feature is to attach a Customer object to each tree node or list item. The examples here are for a control, but the same approach can be used for a control. ### To derive a tree node @@ -94,7 +95,7 @@ You can create a derived node in a Windows Forms class, then you will need to cast to your derived class. Casting is an explicit conversion from one type of object to another. For more information on casting, see [Implicit and Explicit Conversions](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/data-types/implicit-and-explicit-conversions) (Visual Basic), [Casting and type conversions](https://docs.microsoft.com/dotnet/csharp/programming-guide/types/casting-and-type-conversions) (Visual C#), or [Cast Operator: ()](/cpp/cpp/cast-operator-parens) (Visual C++). +2. If you are passed the tree node and it is typed as a class, then you will need to cast to your derived class. Casting is an explicit conversion from one type of object to another. For more information on casting, see [Implicit and Explicit Conversions](/dotnet/visual-basic/programming-guide/language-features/data-types/implicit-and-explicit-conversions) (Visual Basic), [Casting and type conversions](/dotnet/csharp/programming-guide/types/casting-and-type-conversions) (Visual C#), or [Cast Operator: ()](/cpp/cpp/cast-operator-parens) (Visual C++). ```vb Public Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect diff --git a/dotnet-desktop-guide/framework/winforms/controls/add-tables-and-columns-to-wf-datagrid-control-using-the-designer.md b/dotnet-desktop-guide/framework/winforms/controls/add-tables-and-columns-to-wf-datagrid-control-using-the-designer.md index ce85eb7827..3c0a00187c 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/add-tables-and-columns-to-wf-datagrid-control-using-the-designer.md +++ b/dotnet-desktop-guide/framework/winforms/controls/add-tables-and-columns-to-wf-datagrid-control-using-the-designer.md @@ -14,7 +14,7 @@ ms.assetid: 4a6d1b34-b696-476b-bf8a-57c6230aa9e1 You can display data in the Windows Forms control in tables and columns by creating objects and adding them to the object, which is accessed through the control's property. Each table style displays the contents of whatever data table is specified in the property of the . By default, a table style without column styles specified will display all the columns within that data table. You can restrict which columns from the table appear by adding objects to the , which is accessed through the property of each . -The following procedures require a **Windows Application** project with a form that contains a control. For information about how to set up such a project, see [How to: Create a Windows Forms application project](/visualstudio/ide/step-1-create-a-windows-forms-application-project) and [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md). By default in Visual Studio 2005, the control is not in the **Toolbox**. For information about adding it, see [How to: Add Items to the Toolbox](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms165355(v=vs.100)). +The following procedures require a **Windows Application** project with a form that contains a control. For information about how to set up such a project, see [How to: Create a Windows Forms application project](/visualstudio/ide/step-1-create-a-windows-forms-application-project) and [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md). By default in Visual Studio 2005, the control is not in the **Toolbox**. For information about adding it, see [How to: Add Items to the Toolbox](/previous-versions/visualstudio/visual-studio-2010/ms165355(v=vs.100)). ### To add a table to the DataGrid control in the designer diff --git a/dotnet-desktop-guide/framework/winforms/controls/attributes-in-windows-forms-controls.md b/dotnet-desktop-guide/framework/winforms/controls/attributes-in-windows-forms-controls.md index 2ec1357057..bb34e5ce18 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/attributes-in-windows-forms-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/attributes-in-windows-forms-controls.md @@ -9,9 +9,11 @@ helpviewer_keywords: ms.assetid: 2c5640e9-6c6c-49d7-a5e4-a768f6be7853 --- # Attributes in Windows Forms Controls + The .NET Framework provides a variety of attributes you can apply to the members of your custom controls and components. Some of these attributes affect the run-time behavior of a class, and others affect the design-time behavior. ## Attributes for Control and Component Properties + The following table shows the attributes you can apply to properties or other members of your custom controls and components. For an example that uses many of these attributes, see [How to: Apply Attributes in Windows Forms Controls](how-to-apply-attributes-in-windows-forms-controls.md). |Attribute|Description| @@ -32,6 +34,7 @@ The .NET Framework provides a variety of attributes you can apply to the members ||Specifies what type to use as a converter for the object this attribute is bound to.| ## Attributes for Data Binding Properties + The following table shows the attributes you can apply to specify how your custom controls and components interact with data binding. |Attribute|Description| @@ -43,6 +46,7 @@ The .NET Framework provides a variety of attributes you can apply to the members ||Enables attribute redirection.| ## Attributes for Classes + The following table shows the attributes you can apply to specify the behavior of your custom controls and components at design time. |Attribute|Description| @@ -58,5 +62,5 @@ The .NET Framework provides a variety of attributes you can apply to the members - - [How to: Apply Attributes in Windows Forms Controls](how-to-apply-attributes-in-windows-forms-controls.md) -- [Extending Design-Time Support](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) +- [Extending Design-Time Support](/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) - [Developing Custom Windows Forms Controls with the .NET Framework](developing-custom-windows-forms-controls.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/backgroundworker-component-overview.md b/dotnet-desktop-guide/framework/winforms/controls/backgroundworker-component-overview.md index e9a72d637d..28ebdaa664 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/backgroundworker-component-overview.md +++ b/dotnet-desktop-guide/framework/winforms/controls/backgroundworker-component-overview.md @@ -19,6 +19,7 @@ helpviewer_keywords: ms.assetid: 64e9b3ab-7443-4a77-ab17-b8b8c0cb3f62 --- # BackgroundWorker Component Overview + There are many commonly performed operations that can take a long time to execute. For example: - Image downloads @@ -47,15 +48,15 @@ There are many commonly performed operations that can take a long time to execut [!code-csharp[System.ComponentModel.BackgroundWorker#5](~/samples/snippets/csharp/VS_Snippets_Winforms/System.ComponentModel.BackgroundWorker/CS/fibonacciform.cs#5)] [!code-vb[System.ComponentModel.BackgroundWorker#5](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.ComponentModel.BackgroundWorker/VB/fibonacciform.vb#5)] - For more information on using event handlers, see [Events](https://docs.microsoft.com/dotnet/standard/events/index). + For more information on using event handlers, see [Events](/dotnet/standard/events/index). > [!CAUTION] -> When using multithreading of any sort, you potentially expose yourself to very serious and complex bugs. Consult the [Managed Threading Best Practices](https://docs.microsoft.com/dotnet/standard/threading/managed-threading-best-practices) before implementing any solution that uses multithreading. +> When using multithreading of any sort, you potentially expose yourself to very serious and complex bugs. Consult the [Managed Threading Best Practices](/dotnet/standard/threading/managed-threading-best-practices) before implementing any solution that uses multithreading. For more information on using the class, see [How to: Run an Operation in the Background](how-to-run-an-operation-in-the-background.md). ## See also -- [Managed Threading](https://docs.microsoft.com/dotnet/standard/threading/index) -- [Event-based Asynchronous Pattern Overview](https://docs.microsoft.com/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) +- [Managed Threading](/dotnet/standard/threading/index) +- [Event-based Asynchronous Pattern Overview](/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) - [How to: Implement a Form That Uses a Background Operation](how-to-implement-a-form-that-uses-a-background-operation.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/backgroundworker-component.md b/dotnet-desktop-guide/framework/winforms/controls/backgroundworker-component.md index 31c2f14e42..fc59b8c81c 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/backgroundworker-component.md +++ b/dotnet-desktop-guide/framework/winforms/controls/backgroundworker-component.md @@ -13,9 +13,11 @@ helpviewer_keywords: ms.assetid: bef7b0ab-ce57-475a-a2d6-fb8a702a9417 --- # BackgroundWorker Component + The `BackgroundWorker` component enables your form or control to run an operation asynchronously. ## In This Section + [BackgroundWorker Component Overview](backgroundworker-component-overview.md) Describes the `BackgroundWorker` component, which gives you the ability to execute time-consuming operations asynchronously ("in the background"), on a thread different from your application's main UI thread. @@ -35,6 +37,7 @@ The `BackgroundWorker` component enables your form or control to run an operatio Demonstrates how to use the `BackgroundWorker` component to download a file on a separate thread. ## Reference + Describes this class and has links to all its members. @@ -45,5 +48,6 @@ The `BackgroundWorker` component enables your form or control to run an operatio Describes the type that holds data for the event. ## Related Sections - [Event-based Asynchronous Pattern Overview](https://docs.microsoft.com/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) + + [Event-based Asynchronous Pattern Overview](/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) Describes how the asynchronous pattern makes available the advantages of multithreaded applications while hiding many of the complex issues inherent in multithreaded design. diff --git a/dotnet-desktop-guide/framework/winforms/controls/bind-data-to-the-datagrid-using-the-designer.md b/dotnet-desktop-guide/framework/winforms/controls/bind-data-to-the-datagrid-using-the-designer.md index 2d3049e250..0f7397aad2 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/bind-data-to-the-datagrid-using-the-designer.md +++ b/dotnet-desktop-guide/framework/winforms/controls/bind-data-to-the-datagrid-using-the-designer.md @@ -8,11 +8,12 @@ helpviewer_keywords: ms.assetid: f4f46009-cec2-441b-8668-6b5af057558b --- # How to: Bind Data to the Windows Forms DataGridView Control Using the Designer + You can use the designer to connect a control to data sources of several different varieties, including databases, business objects, or Web services. When you bind the control to a data source using the designer, the control is automatically bound to a component that represents the data source. Additionally, columns are automatically generated in the control to match the schema information provided by the data source. After columns have been generated, you can modify them to meet your needs. For example, you can remove or hide columns you are not interested in displaying, you can rearrange the columns, or you can modify the column types. For more information about modifying columns, see the topics listed in the See Also section. - You can also bind multiple controls to related tables to create master/detail relationships. In this configuration, one control displays a parent table and another control displays only those rows from a child table that are related to the current row in the parent table. For more information, see [How to: Display Related Data in a Windows Forms Application](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/57tx3hhe(v=vs.120)). + You can also bind multiple controls to related tables to create master/detail relationships. In this configuration, one control displays a parent table and another control displays only those rows from a child table that are related to the current row in the parent table. For more information, see [How to: Display Related Data in a Windows Forms Application](/previous-versions/visualstudio/visual-studio-2013/57tx3hhe(v=vs.120)). The following procedure requires a **Windows Application** project with a form that contains a control or two controls for a master/detail relationship. For information about starting such a project, see [How to: Create a Windows Forms application project](/visualstudio/ide/step-1-create-a-windows-forms-application-project) and [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md). @@ -24,7 +25,7 @@ You can use the designer to connect a c 3. If your project does not already have a data source, click **Add Project Data Source** and follow the steps indicated by the wizard. - For more information, see [Data Source Configuration Wizard](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/w4dd7z6t(v=vs.120)). Your new data source will appear in the **Choose Data Source** drop-down window. If your new data source contains only one member, such as a single database table, the control will automatically bind to that member. Otherwise, continue to the next step. + For more information, see [Data Source Configuration Wizard](/previous-versions/visualstudio/visual-studio-2013/w4dd7z6t(v=vs.120)). Your new data source will appear in the **Choose Data Source** drop-down window. If your new data source contains only one member, such as a single database table, the control will automatically bind to that member. Otherwise, continue to the next step. 4. Expand the **Other Data Sources** and **Project Data Sources** nodes if they are not already expanded, and then select the data source to bind the control to. @@ -33,7 +34,7 @@ You can use the designer to connect a c 6. To create a master/detail relationship, in the **Choose Data Source** drop-down window for a second control, expand the created for the parent table, and then select the related child table from the list shown. > [!NOTE] - > If your project already has a data source, you can also use the **Data Sources** window to create a data form. For more information, see [Data Sources Window](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/6ckyxa83(v=vs.120)). + > If your project already has a data source, you can also use the **Data Sources** window to create a data form. For more information, see [Data Sources Window](/previous-versions/visualstudio/visual-studio-2013/6ckyxa83(v=vs.120)). ## See also @@ -41,7 +42,7 @@ You can use the designer to connect a c - - - -- [How to: Connect to Data in a Database](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/fxk9yw1t(v=vs.120)) +- [How to: Connect to Data in a Database](/previous-versions/visualstudio/visual-studio-2013/fxk9yw1t(v=vs.120)) - [How to: Add and Remove Columns in the Windows Forms DataGridView Control Using the Designer](add-and-remove-columns-in-the-datagrid-using-the-designer.md) - [How to: Change the Order of Columns in the Windows Forms DataGridView Control Using the Designer](change-the-order-of-columns-in-the-datagrid-using-the-designer.md) - [How to: Change the Type of a Windows Forms DataGridView Column Using the Designer](change-the-type-of-a-wf-datagridview-column-using-the-designer.md) @@ -50,5 +51,5 @@ You can use the designer to connect a c - [How to: Make Columns Read-Only in the Windows Forms DataGridView Control Using the Designer](make-columns-read-only-in-the-datagrid-using-the-designer.md) - [How to: Create a Windows Forms application project](/visualstudio/ide/step-1-create-a-windows-forms-application-project) - [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md) -- [Data Sources Window](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/6ckyxa83(v=vs.120)) -- [How to: Display Related Data in a Windows Forms Application](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/57tx3hhe(v=vs.120)) +- [Data Sources Window](/previous-versions/visualstudio/visual-studio-2013/6ckyxa83(v=vs.120)) +- [How to: Display Related Data in a Windows Forms Application](/previous-versions/visualstudio/visual-studio-2013/57tx3hhe(v=vs.120)) diff --git a/dotnet-desktop-guide/framework/winforms/controls/bind-wf-controls-with-the-bindingsource.md b/dotnet-desktop-guide/framework/winforms/controls/bind-wf-controls-with-the-bindingsource.md index c026907593..26b06108c5 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/bind-wf-controls-with-the-bindingsource.md +++ b/dotnet-desktop-guide/framework/winforms/controls/bind-wf-controls-with-the-bindingsource.md @@ -8,6 +8,7 @@ helpviewer_keywords: ms.assetid: 391ae170-de5c-40f8-8233-91cb2ee4683a --- # How to: Bind Windows Forms Controls with the BindingSource Component Using the Designer + After you have added controls to your form and determined the user interface for your application, you can bind the controls to a data source, so that, at run time, users can alter and save data related to the application. Binding a control or series of controls in Windows Forms is most easily accomplished using the control as a bridge between the controls on the form and the data source. @@ -55,4 +56,4 @@ After you have added controls to your form and determined the user interface for - - - [Add new data sources](/visualstudio/data-tools/add-new-data-sources) -- [Data Sources Window](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/6ckyxa83(v=vs.120)) +- [Data Sources Window](/previous-versions/visualstudio/visual-studio-2013/6ckyxa83(v=vs.120)) diff --git a/dotnet-desktop-guide/framework/winforms/controls/bind-wf-datagrid-control-to-a-data-source-using-the-designer.md b/dotnet-desktop-guide/framework/winforms/controls/bind-wf-datagrid-control-to-a-data-source-using-the-designer.md index 8b48542611..308bbeeb1d 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/bind-wf-datagrid-control-to-a-data-source-using-the-designer.md +++ b/dotnet-desktop-guide/framework/winforms/controls/bind-wf-datagrid-control-to-a-data-source-using-the-designer.md @@ -24,7 +24,7 @@ ms.assetid: 4e96e3d0-b1cc-4de1-8774-bc9970ec4554 You can also bind the grid programmatically, at run time. This is useful when you want to set a data source based on information you get at run time. For example, the application might let the user specify the name of a table to view. It is also necessary in situations where the data source does not exist at design time. This includes data sources such as arrays, collections, untyped datasets, and data readers. - The following procedure requires a **Windows Application** project with a form containing a control. For information about setting up such a project, see [How to: Create a Windows Forms application project](/visualstudio/ide/step-1-create-a-windows-forms-application-project) and [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md). In Visual Studio 2005, the control is not in the **Toolbox** by default. For information about adding it, see [How to: Add Items to the Toolbox](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms165355(v=vs.100)). Additionally in Visual Studio 2005, you can use the **Data Sources** window for design-time data binding. For more information see [Bind controls to data in Visual Studio](/visualstudio/data-tools/bind-controls-to-data-in-visual-studio). + The following procedure requires a **Windows Application** project with a form containing a control. For information about setting up such a project, see [How to: Create a Windows Forms application project](/visualstudio/ide/step-1-create-a-windows-forms-application-project) and [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md). In Visual Studio 2005, the control is not in the **Toolbox** by default. For information about adding it, see [How to: Add Items to the Toolbox](/previous-versions/visualstudio/visual-studio-2010/ms165355(v=vs.100)). Additionally in Visual Studio 2005, you can use the **Data Sources** window for design-time data binding. For more information see [Bind controls to data in Visual Studio](/visualstudio/data-tools/bind-controls-to-data-in-visual-studio). ## To data-bind the DataGrid control to a single table in the designer diff --git a/dotnet-desktop-guide/framework/winforms/controls/button-control-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/button-control-windows-forms.md index 4b73c93628..090b0908aa 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/button-control-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/button-control-windows-forms.md @@ -7,9 +7,11 @@ helpviewer_keywords: ms.assetid: d38bc40c-8040-4f19-9e88-2c665b0ab80b --- # Button Control (Windows Forms) + The Windows Forms `Button` control allows the user to click it to perform an action. The `Button` control can display both text and images. When the button is clicked, it looks as if it is being pushed in and released. ## In This Section + [Button Control Overview](button-control-overview-windows-forms.md) Explains what this control is and its key features and properties. @@ -28,11 +30,13 @@ The Windows Forms `Button` control allows the user to click it to perform an act Also see [How to: Designate a Windows Forms Button as the Accept Button Using the Designer](designate-a-wf-button-as-the-accept-button-using-the-designer.md) and [How to: Designate a Windows Forms Button as the Cancel Button Using the Designer](designate-a-wf-button-as-the-cancel-button-using-the-designer.md). ## Reference + class Describes this class and has links to all its members. ## Related Sections + [Controls to Use on Windows Forms](controls-to-use-on-windows-forms.md) Provides a complete list of Windows Forms controls, with links to information on their use. - Also see [User Input to Dialog Boxes](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/1s9ws53w(v=vs.100)) and [How to: Close Dialog Boxes and Retain User Input](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/65ad5907(v=vs.100)). + Also see [User Input to Dialog Boxes](/previous-versions/visualstudio/visual-studio-2010/1s9ws53w(v=vs.100)) and [How to: Close Dialog Boxes and Retain User Input](/previous-versions/visualstudio/visual-studio-2010/65ad5907(v=vs.100)). diff --git a/dotnet-desktop-guide/framework/winforms/controls/change-displayed-data-at-run-time-wf-datagrid-control.md b/dotnet-desktop-guide/framework/winforms/controls/change-displayed-data-at-run-time-wf-datagrid-control.md index 48c3b4fdb8..ee69bc9199 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/change-displayed-data-at-run-time-wf-datagrid-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/change-displayed-data-at-run-time-wf-datagrid-control.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: 0c7a6d00-30de-416e-8223-0a81ddb4c1f8 --- # How to: Change Displayed Data at Run Time in the Windows Forms DataGrid Control + > [!NOTE] > The control replaces and adds functionality to the control; however, the control is retained for both backward compatibility and future use, if you choose. For more information, see [Differences Between the Windows Forms DataGridView and DataGrid Controls](differences-between-the-windows-forms-datagridview-and-datagrid-controls.md). @@ -89,7 +90,7 @@ ms.assetid: 0c7a6d00-30de-416e-8223-0a81ddb4c1f8 ## See also -- [ADO.NET DataSets](https://docs.microsoft.com/dotnet/framework/data/adonet/ado-net-datasets) +- [ADO.NET DataSets](/dotnet/framework/data/adonet/ado-net-datasets) - [How to: Delete or Hide Columns in the Windows Forms DataGrid Control](how-to-delete-or-hide-columns-in-the-windows-forms-datagrid-control.md) - [How to: Add Tables and Columns to the Windows Forms DataGrid Control](how-to-add-tables-and-columns-to-the-windows-forms-datagrid-control.md) - [How to: Bind the Windows Forms DataGrid Control to a Data Source](how-to-bind-the-windows-forms-datagrid-control-to-a-data-source.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/considerations-when-hosting-an-activex-control-on-a-windows-form.md b/dotnet-desktop-guide/framework/winforms/controls/considerations-when-hosting-an-activex-control-on-a-windows-form.md index 017af200e7..08418ea5ce 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/considerations-when-hosting-an-activex-control-on-a-windows-form.md +++ b/dotnet-desktop-guide/framework/winforms/controls/considerations-when-hosting-an-activex-control-on-a-windows-form.md @@ -10,6 +10,7 @@ helpviewer_keywords: ms.assetid: 2509302d-a74e-484f-9890-2acdbfa67a68 --- # Considerations When Hosting an ActiveX Control on a Windows Form + Although Windows Forms have been optimized to host Windows Forms controls, you can still use ActiveX controls. Keep the following considerations in mind when planning an application that uses ActiveX controls: - **Security** The common language runtime has been enhanced with regard to code access security. Applications featuring Windows Forms can run in a fully trusted environment without issue and in a semi-trusted environment with most of the functionality accessible. Windows Forms controls can be hosted in a browser with no complications. However, ActiveX controls on Windows Forms cannot take advantage of these security enhancements. Running an ActiveX control requires unmanaged code permission, which is set with the property. For more information about security and unmanaged code permission, see . @@ -17,15 +18,14 @@ Although Windows Forms have been optimized to host Windows Forms controls, you c - **Total Cost of Ownership** ActiveX controls added to a Windows Form are deployed with that Windows Form in their entirety, which can add significantly to the size of the file(s) created. Additionally, using ActiveX controls on Windows Forms requires writing to the registry. This is more invasive to a user's computer than Windows Forms controls, which do not require this. > [!NOTE] - > Working with an ActiveX control requires the use of a COM interop wrapper. For more information, see [COM Interoperability in Visual Basic and Visual C#](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/com-interop/com-interoperability-in-net-framework-applications). - + > Working with an ActiveX control requires the use of a COM interop wrapper. For more information, see [COM Interoperability in Visual Basic and Visual C#](/dotnet/visual-basic/programming-guide/com-interop/com-interoperability-in-net-framework-applications). > [!NOTE] > If the name of a member of the ActiveX control matches a name defined in the .NET Framework, then the ActiveX Control Importer will prefix the member name with **Ctl** when it creates the derived class. For example, if your ActiveX control has a member named **Layout**, it is renamed **CtlLayout** in the AxHost-derived class because the **Layout** event is defined within the .NET Framework. ## See also - [How to: Add ActiveX Controls to Windows Forms](how-to-add-activex-controls-to-windows-forms.md) -- [Code Access Security](https://docs.microsoft.com/dotnet/framework/misc/code-access-security) -- [Controls and Programmable Objects Compared in Various Languages and Libraries](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/0061wezk(v=vs.100)) +- [Code Access Security](/dotnet/framework/misc/code-access-security) +- [Controls and Programmable Objects Compared in Various Languages and Libraries](/previous-versions/visualstudio/visual-studio-2010/0061wezk(v=vs.100)) - [Putting Controls on Windows Forms](putting-controls-on-windows-forms.md) - [Windows Forms Controls](index.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/contextmenustrip-control.md b/dotnet-desktop-guide/framework/winforms/controls/contextmenustrip-control.md index 8541ced07e..deed1f6129 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/contextmenustrip-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/contextmenustrip-control.md @@ -8,9 +8,11 @@ helpviewer_keywords: ms.assetid: 76e070b2-65d7-457f-8300-d104e4e01e5e --- # ContextMenuStrip Control + The control provides a shortcut menu that you associate with a control. ## In This Section + [ContextMenuStrip Control Overview](contextmenustrip-control-overview.md) Explains what the control is and its key features and properties. @@ -29,9 +31,10 @@ The control provides a shortcut men [How to: Handle the ContextMenuStrip Opening Event](how-to-handle-the-contextmenustrip-opening-event.md) Describes how to customize the behavior of a control by handling the event. - Also see [ContextMenuStrip Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233646(v=vs.100)) or [ContextMenuStrip Items Collection Editor](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233641(v=vs.100)). + Also see [ContextMenuStrip Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233646(v=vs.100)) or [ContextMenuStrip Items Collection Editor](/previous-versions/visualstudio/visual-studio-2010/ms233641(v=vs.100)). ## Reference + Describes the features of the class, which provides a menu system for a form. @@ -42,5 +45,6 @@ The control provides a shortcut men Describes the features of the class, which represents a selectable option displayed on a or . ## Related Sections + [Controls to Use on Windows Forms](controls-to-use-on-windows-forms.md) Provides a complete list of Windows Forms controls, with links to information on their use. diff --git a/dotnet-desktop-guide/framework/winforms/controls/control-type-recommendations.md b/dotnet-desktop-guide/framework/winforms/controls/control-type-recommendations.md index 85e133bbb5..8b163b2e07 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/control-type-recommendations.md +++ b/dotnet-desktop-guide/framework/winforms/controls/control-type-recommendations.md @@ -13,7 +13,7 @@ ms.assetid: 5235fe9d-c36a-4c08-ae76-6cb90b50085e The .NET Framework gives you power to develop and implement new controls. In addition to the familiar user control, you will now find that you are able to write custom controls that perform their own painting, and are even able to extend the functionality of existing controls through inheritance. Deciding which type of control to create can be confusing. This section highlights the differences between the various types of controls from which you can inherit, and gives considerations regarding the type to choose for your project. > [!NOTE] -> If you want to author a control to use on Web Forms, see [Developing Custom ASP.NET Server Controls](https://docs.microsoft.com/previous-versions/aspnet/zt27tfhy(v=vs.100)). +> If you want to author a control to use on Web Forms, see [Developing Custom ASP.NET Server Controls](/previous-versions/aspnet/zt27tfhy(v=vs.100)). ## Inheriting from a Windows Forms Control @@ -73,7 +73,7 @@ Inherit from the class if: - [Walkthrough: Creating a Windows Forms Control That Takes Advantage of Visual Studio Design-Time Features](creating-a-wf-control-design-time-features.md) -- [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)) +- [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)) ## See also diff --git a/dotnet-desktop-guide/framework/winforms/controls/controls-to-use-on-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/controls-to-use-on-windows-forms.md index 689be23c3c..b6f4566565 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/controls-to-use-on-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/controls-to-use-on-windows-forms.md @@ -8,12 +8,14 @@ helpviewer_keywords: ms.assetid: dec51976-eae0-4398-a537-20bca7974722 --- # Controls to Use on Windows Forms + The following is an alphabetic list of controls and components that can be used on Windows Forms. In addition to the Windows Forms controls covered in this section, you can add ActiveX and custom controls to Windows Forms. If you do not find the control you need listed here, you can also create your own. For details, see [Developing Windows Forms Controls at Design Time](developing-windows-forms-controls-at-design-time.md). For more information about choosing the control you need, see [Windows Forms Controls by Function](windows-forms-controls-by-function.md). > [!NOTE] > Visual Basic controls are based on classes provided by the .NET Framework. ## In This Section + [Windows Forms Controls by Function](windows-forms-controls-by-function.md) Lists and describes Windows Forms controls based on the .NET Framework. @@ -219,13 +221,14 @@ The following is an alphabetic list of controls and components that can be used Describes a set of controls used to provide users with a list of options to choose from. ## Related Sections + [Windows Forms Controls](index.md) Explains the use of Windows Forms controls, and describes important concepts for working with them. [Developing Windows Forms Controls at Design Time](developing-windows-forms-controls-at-design-time.md) Provides links to step-by-step topics, recommendations for which kind of control to create, and other information about creating your own control. - [Controls and Programmable Objects Compared in Various Languages and Libraries](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/0061wezk(v=vs.100)) + [Controls and Programmable Objects Compared in Various Languages and Libraries](/previous-versions/visualstudio/visual-studio-2010/0061wezk(v=vs.100)) Provides a table that maps controls in Visual Basic 6.0 to the corresponding control in Visual Basic .NET. Note that controls are now classes in the .NET Framework. [How to: Add ActiveX Controls to Windows Forms](how-to-add-activex-controls-to-windows-forms.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/create-a-lookup-table-for-a-wf-combobox-listbox.md b/dotnet-desktop-guide/framework/winforms/controls/create-a-lookup-table-for-a-wf-combobox-listbox.md index 2c89f789b9..13c5a104a5 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/create-a-lookup-table-for-a-wf-combobox-listbox.md +++ b/dotnet-desktop-guide/framework/winforms/controls/create-a-lookup-table-for-a-wf-combobox-listbox.md @@ -16,6 +16,7 @@ helpviewer_keywords: ms.assetid: 4ce35f12-1f4e-4317-92d1-af8686a8cfaa --- # How to: Create a Lookup Table for a Windows Forms ComboBox, ListBox, or CheckedListBox Control + Sometimes it is useful to display data in a user-friendly format on a Windows Form, but store the data in a format that is more meaningful to your program. For example, an order form for food might display the menu items by name in a list box. However, the data table recording the order would contain the unique ID numbers representing the food. The following tables show an example of how to store and display order-form data for food. ### OrderDetailsTable @@ -44,7 +45,7 @@ Sometimes it is useful to display data in a user-friendly format on a Windows Fo 2. Connect to your data source. -3. Establish a data relation between the two tables. See [Introduction to DataRelation Objects](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/0k21zcyx(v=vs.120)). +3. Establish a data relation between the two tables. See [Introduction to DataRelation Objects](/previous-versions/visualstudio/visual-studio-2013/0k21zcyx(v=vs.120)). 4. Set the following properties. They can be set in code or in the designer. diff --git a/dotnet-desktop-guide/framework/winforms/controls/create-a-master-detail-form-using-two-datagridviews.md b/dotnet-desktop-guide/framework/winforms/controls/create-a-master-detail-form-using-two-datagridviews.md index 900a51fd17..dfe282b1ef 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/create-a-master-detail-form-using-two-datagridviews.md +++ b/dotnet-desktop-guide/framework/winforms/controls/create-a-master-detail-form-using-two-datagridviews.md @@ -11,6 +11,7 @@ helpviewer_keywords: ms.assetid: 99f6e876-3f7f-4139-9063-e36587c95b02 --- # How to: Create a Master/Detail Form Using Two Windows Forms DataGridView Controls + The following code example creates a master/detail form using two controls bound to two components. The data source is a that contains the `Customers` and `Orders` tables from the Northwind SQL Server sample database along with a that relates the two through the `CustomerID` column. One is bound to the parent `Customers` table in the data set. This data is displayed in the master control. The other is bound to the first data connector. The property of the second is set to the name. This causes the associated detail control to display the rows of the child `Orders` table that correspond to the current row in the master control. @@ -18,16 +19,19 @@ The following code example creates a master/detail form using two - [Walkthrough: Creating a Master/Detail Form Using Two Windows Forms DataGridView Controls](creating-a-master-detail-form-using-two-datagridviews.md) - [Displaying Data in the Windows Forms DataGridView Control](displaying-data-in-the-windows-forms-datagridview-control.md) -- [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information) +- [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information) diff --git a/dotnet-desktop-guide/framework/winforms/controls/create-master-details-lists-with-wf-datagrid-control-using-the-designer.md b/dotnet-desktop-guide/framework/winforms/controls/create-master-details-lists-with-wf-datagrid-control-using-the-designer.md index d6e73f7cd3..9a45b2b19e 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/create-master-details-lists-with-wf-datagrid-control-using-the-designer.md +++ b/dotnet-desktop-guide/framework/winforms/controls/create-master-details-lists-with-wf-datagrid-control-using-the-designer.md @@ -18,10 +18,10 @@ ms.assetid: 19438ba2-f687-4417-a2fb-ab1cd69d4ded ## To create a master-details list in the designer -1. Add two controls to the form. For more information, see [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md). In Visual Studio 2005, the control is not in the **Toolbox** by default. For more information, see [How to: Add Items to the Toolbox](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms165355(v=vs.100)). +1. Add two controls to the form. For more information, see [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md). In Visual Studio 2005, the control is not in the **Toolbox** by default. For more information, see [How to: Add Items to the Toolbox](/previous-versions/visualstudio/visual-studio-2010/ms165355(v=vs.100)). > [!NOTE] - > The following steps are not applicable to Visual Studio 2005, which uses the **Data Sources** window for design-time data binding. For more information, see [Bind controls to data in Visual Studio](/visualstudio/data-tools/bind-controls-to-data-in-visual-studio) and [How to: Display Related Data in a Windows Forms Application](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/57tx3hhe(v=vs.120)). + > The following steps are not applicable to Visual Studio 2005, which uses the **Data Sources** window for design-time data binding. For more information, see [Bind controls to data in Visual Studio](/visualstudio/data-tools/bind-controls-to-data-in-visual-studio) and [How to: Display Related Data in a Windows Forms Application](/previous-versions/visualstudio/visual-studio-2013/57tx3hhe(v=vs.120)). 2. Drag two or more tables from **Server Explorer** to the form. diff --git a/dotnet-desktop-guide/framework/winforms/controls/creating-a-master-detail-form-using-two-datagridviews.md b/dotnet-desktop-guide/framework/winforms/controls/creating-a-master-detail-form-using-two-datagridviews.md index 2210a14565..46ce7d73c1 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/creating-a-master-detail-form-using-two-datagridviews.md +++ b/dotnet-desktop-guide/framework/winforms/controls/creating-a-master-detail-form-using-two-datagridviews.md @@ -39,7 +39,7 @@ In order to complete this walkthrough, you will need: 2. Implement a method in your form's class definition for handling the detail of connecting to the database. This example uses a `GetData` method that populates a object, adds a object to the data set, and binds the components. Be sure to set the `connectionString` variable to a value that is appropriate for your database. > [!IMPORTANT] - > Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information). + > Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information). [!code-csharp[System.Windows.Forms.DataGridViewMasterDetails#20](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMasterDetails/CS/masterdetails.cs#20)] [!code-vb[System.Windows.Forms.DataGridViewMasterDetails#20](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMasterDetails/VB/masterdetails.vb#20)] @@ -79,4 +79,4 @@ This application gives you a basic understanding of the - [Displaying Data in the Windows Forms DataGridView Control](displaying-data-in-the-windows-forms-datagridview-control.md) - [How to: Create a Master/Detail Form Using Two Windows Forms DataGridView Controls](create-a-master-detail-form-using-two-datagridviews.md) -- [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information) +- [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information) diff --git a/dotnet-desktop-guide/framework/winforms/controls/creating-a-wf-control-design-time-features.md b/dotnet-desktop-guide/framework/winforms/controls/creating-a-wf-control-design-time-features.md index dfa48098fe..73e9220dde 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/creating-a-wf-control-design-time-features.md +++ b/dotnet-desktop-guide/framework/winforms/controls/creating-a-wf-control-design-time-features.md @@ -29,7 +29,7 @@ When you're finished with this walkthrough, your custom control will look someth ![The app showing a marquee saying Text and a Start and Stop buttons.](./media/creating-a-wf-control-design-time-features/demo-marquee-control.gif) -For the complete code listing, see [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)). +For the complete code listing, see [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)). ## Prerequisites @@ -601,7 +601,7 @@ The `MarqueeControlLibrary` demonstrates a simple implementation of custom contr - License the `MarqueeControl`. -- Control how your controls are serialized and how code is generated for them. For more information, see [Dynamic Source Code Generation and Compilation](https://docs.microsoft.com/dotnet/framework/reflection-and-codedom/dynamic-source-code-generation-and-compilation). +- Control how your controls are serialized and how code is generated for them. For more information, see [Dynamic Source Code Generation and Compilation](/dotnet/framework/reflection-and-codedom/dynamic-source-code-generation-and-compilation). ## See also diff --git a/dotnet-desktop-guide/framework/winforms/controls/data-formatting-in-the-windows-forms-datagridview-control.md b/dotnet-desktop-guide/framework/winforms/controls/data-formatting-in-the-windows-forms-datagridview-control.md index 74481fc864..b65040c23d 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/data-formatting-in-the-windows-forms-datagridview-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/data-formatting-in-the-windows-forms-datagridview-control.md @@ -8,14 +8,17 @@ helpviewer_keywords: ms.assetid: 07bf558d-3748-42ba-8ba0-37fdef924081 --- # Data Formatting in the Windows Forms DataGridView Control + The control provides automatic conversion between cell values and the data types that the parent columns display. Text box columns, for example, display string representations of date, time, number, and enumeration values, and convert user-entered string values to the types required by the data store. ## Formatting with the DataGridViewCellStyle class - The control provides basic data formatting of cell values through the class. You can use the property to format date, time, number, and enumeration values for the current default culture using the format specifiers described in [Formatting Types](https://docs.microsoft.com/dotnet/standard/base-types/formatting-types). You can also format these values for specific cultures using the property. The specified format is used both to display data and to parse data that the user enters in the specified format. + + The control provides basic data formatting of cell values through the class. You can use the property to format date, time, number, and enumeration values for the current default culture using the format specifiers described in [Formatting Types](/dotnet/standard/base-types/formatting-types). You can also format these values for specific cultures using the property. The specified format is used both to display data and to parse data that the user enters in the specified format. The class provides additional formatting properties for wordwrap, text alignment, and the custom display of null database values. For more information, see [How to: Format Data in the Windows Forms DataGridView Control](how-to-format-data-in-the-windows-forms-datagridview-control.md). ## Formatting with the CellFormatting Event + If the basic formatting does not meet your needs, you can provide custom data formatting in a handler for the event. The passed to the handler has a property that initially contains the cell value. Normally, this value is automatically converted to the display type. To convert the value yourself, set the property to a value of the display type. > [!NOTE] diff --git a/dotnet-desktop-guide/framework/winforms/controls/datagridview-control-technology-summary-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/datagridview-control-technology-summary-windows-forms.md index a55983ed28..aa92528edd 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/datagridview-control-technology-summary-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/datagridview-control-technology-summary-windows-forms.md @@ -7,22 +7,27 @@ helpviewer_keywords: ms.assetid: 094498c3-a126-4a3f-83fe-f69e96c7717b --- # DataGridView Control Technology Summary (Windows Forms) + This topic summarizes information about the `DataGridView` control and the classes that support its use. Displaying data in a tabular format is a task you are likely to perform frequently. The `DataGridView` control is designed to be a complete solution for presenting data in a grid. ## Keywords + DataGridView, BindingSource, table, cell, data binding, virtual mode ## Namespaces + ## Related Technologies + `BindingSource` ## Background + User interface (UI) designers frequently find it necessary to display tabular data to users. The .NET Framework provides several ways to show data in a table or grid. The `DataGridView` control represents the latest evolution of this technology for Windows Forms applications. The `DataGridView` control can display rows of data from a data store. Many types of data stores are supported. The data store can hold simple, untyped data, such as a one-dimensional array, or it can hold typed data, such as a . For more information, see [How to: Bind Data to the Windows Forms DataGridView Control](how-to-bind-data-to-the-windows-forms-datagridview-control.md). @@ -32,6 +37,7 @@ This topic summarizes information about the `DataGridView` control and the class You can extend the `DataGridView` control in several ways to build custom behavior into your applications. For example, you can programmatically specify your own sorting algorithms, and you can create your own types of cells. You can easily customize the appearance of the `DataGridView` control by choosing among several properties. Many types of data stores can be used as a data source, or the `DataGridView` control can operate without a data source bound to it. ## Implementing DataGridView Classes + There are several ways for you to take advantage of the `DataGridView` control's extensibility features. You can customize many aspects of the control through events and properties, but some customizations require you to create new classes derived from existing `DataGridView` classes. The most typically used base classes are `DataGridViewCell` and `DataGridViewColumn`. You can derive your own cell class from `DataGridViewCell` or any of its child classes. Although you can add any cell type to any column, you will typically also derive a companion column class from `DataGridViewColumn` that hosts cells of your custom cell type by default. @@ -41,6 +47,7 @@ This topic summarizes information about the `DataGridView` control and the class For more information, see [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](customize-cells-and-columns-in-the-datagrid-by-extending-behavior.md) and [How to: Host Controls in Windows Forms DataGridView Cells](how-to-host-controls-in-windows-forms-datagridview-cells.md). ## DataGridView Classes at a Glance + |Technology Area|Classes/interfaces/configuration elements| @@ -50,6 +57,7 @@ This topic summarizes information about the `DataGridView` control and the class | Extensibility| and derived classes

and derived classes



| ## What's New + The control is designed to be a complete solution for displaying tabular data with Windows Forms. You should consider using the control before other solutions, such as , when you are authoring a new application. For more information, see [Differences Between the Windows Forms DataGridView and DataGrid Controls](differences-between-the-windows-forms-datagridview-and-datagrid-controls.md). The control can work in close conjunction with the component. This component is designed to be the primary data source of a form. It can manage the interaction between a control and its data source, regardless of the data source type. @@ -58,4 +66,4 @@ This topic summarizes information about the `DataGridView` control and the class - [DataGridView Control Overview](datagridview-control-overview-windows-forms.md) - [DataGridView Control Architecture](datagridview-control-architecture-windows-forms.md) -- [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information) +- [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information) diff --git a/dotnet-desktop-guide/framework/winforms/controls/defining-a-property-in-windows-forms-controls.md b/dotnet-desktop-guide/framework/winforms/controls/defining-a-property-in-windows-forms-controls.md index 29128bd64f..e3a28da02b 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/defining-a-property-in-windows-forms-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/defining-a-property-in-windows-forms-controls.md @@ -10,16 +10,17 @@ helpviewer_keywords: ms.assetid: c2eb8277-a842-4d99-89a9-647b901a0434 --- # Defining a Property in Windows Forms Controls -For an overview of properties, see [Properties Overview](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/65zdfbdt(v=vs.120)). There are a few important considerations when defining a property: + +For an overview of properties, see [Properties Overview](/previous-versions/visualstudio/visual-studio-2013/65zdfbdt(v=vs.120)). There are a few important considerations when defining a property: -- You must apply attributes to the properties you define. Attributes specify how the designer should display a property. For details, see [Design-Time Attributes for Components](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/tk67c2t8(v=vs.120)). +- You must apply attributes to the properties you define. Attributes specify how the designer should display a property. For details, see [Design-Time Attributes for Components](/previous-versions/visualstudio/visual-studio-2013/tk67c2t8(v=vs.120)). - If changing the property affects the visual display of the control, call the method (that your control inherits from ) from the `set` accessor. in turn calls the method, which redraws the control. Multiple calls to result in a single call to for efficiency. - The .NET Framework class library provides type converters for common data types such as integers, decimal numbers, Boolean values, and others. The purpose of a type converter is generally to provide string-to-value conversion (from string data to other data types). Common data types are associated with default type converters that convert values into strings and strings into the appropriate data types. If you define a property that is a custom (that is, nonstandard) data type, you will have to apply an attribute that specifies the type converter to associate with that property. You can also use an attribute to associate a custom UI type editor with a property. A UI type editor provides a user interface for editing a property or data type. A color picker is an example of a UI type editor. Examples of attributes are given at the end of this topic. > [!NOTE] - > If a type converter or a UI type editor is not available for your custom property, you can implement one as described in [Extending Design-Time Support](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)). + > If a type converter or a UI type editor is not available for your custom property, you can implement one as described in [Extending Design-Time Support](/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)). The following code fragment defines a custom property named `EndColor` for the custom control `FlashTrackBar`. diff --git a/dotnet-desktop-guide/framework/winforms/controls/defining-an-event-in-windows-forms-controls.md b/dotnet-desktop-guide/framework/winforms/controls/defining-an-event-in-windows-forms-controls.md index ffb3686fa6..24eb42e92f 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/defining-an-event-in-windows-forms-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/defining-an-event-in-windows-forms-controls.md @@ -10,7 +10,8 @@ helpviewer_keywords: ms.assetid: d89f1096-8061-42e2-a855-a1f053f1940a --- # Defining an Event in Windows Forms Controls -For details about defining custom events, see [Events](https://docs.microsoft.com/dotnet/standard/events/index). If you define an event that does not have any associated data, use the base type for event data, , and use as the event delegate. All that remains to do is to define an event member and a protected `On`*EventName* method that raises the event. + +For details about defining custom events, see [Events](/dotnet/standard/events/index). If you define an event that does not have any associated data, use the base type for event data, , and use as the event delegate. All that remains to do is to define an event member and a protected `On`*EventName* method that raises the event. The following code fragment shows how the `FlashTrackBar` custom control defines a custom event, `ValueChanged`. For the complete code for the `FlashTrackBar` sample, see the [How to: Create a Windows Forms Control That Shows Progress](how-to-create-a-windows-forms-control-that-shows-progress.md). @@ -73,4 +74,4 @@ public class FlashTrackBar : Control { ## See also - [Events in Windows Forms Controls](events-in-windows-forms-controls.md) -- [Events](https://docs.microsoft.com/dotnet/standard/events/index) +- [Events](/dotnet/standard/events/index) diff --git a/dotnet-desktop-guide/framework/winforms/controls/design-time-errors-in-the-windows-forms-designer.md b/dotnet-desktop-guide/framework/winforms/controls/design-time-errors-in-the-windows-forms-designer.md index db11dd088e..3afeb659d7 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/design-time-errors-in-the-windows-forms-designer.md +++ b/dotnet-desktop-guide/framework/winforms/controls/design-time-errors-in-the-windows-forms-designer.md @@ -169,7 +169,7 @@ Visual Studio attempted to wire up an event-handling method and could not find o The templates for inherited forms in Visual Studio are not available. If you see this error, please log an issue by using [Report a Problem](/visualstudio/ide/how-to-report-a-problem-with-visual-studio). -### Delegate class '\' has no invoke method. Is this class a delegate? +### Delegate class '\' has no invoke method. Is this class a delegate Visual Studio has tried to create an event handler, but there is something wrong with the event type. This can happen if the event was created by a non-CLS-compliant language. Contact the component vendor. @@ -209,7 +209,7 @@ You've tried to rename a component to an invalid value for that language. To cor ### The type '\' is made of several partial classes in the same file -When you define a class in multiple files by using the [partial](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/partial-type) keyword, you can only have one partial definition in each file. +When you define a class in multiple files by using the [partial](/dotnet/csharp/language-reference/keywords/partial-type) keyword, you can only have one partial definition in each file. To correct this error, remove all but one of the partial definitions of your class from the file. @@ -257,7 +257,7 @@ Visual Studio could not load the designer for the class. If you see this error, ### The designer must create an instance of type '\', but it can't because the type is declared as abstract -This error occurred because the base class of the object being passed to the designer is [abstract](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/abstract), which is not allowed. +This error occurred because the base class of the object being passed to the designer is [abstract](/dotnet/csharp/language-reference/keywords/abstract), which is not allowed. ### The file could not be loaded in the designer @@ -359,7 +359,7 @@ This message is similar to "The language for this file does not support the nece ### Type '\' does not have a constructor with parameters of types '\' -Visual Studio could not find a [constructor](https://docs.microsoft.com/dotnet/csharp/programming-guide/classes-and-structs/constructors) that had matching parameters. This may be the result of supplying a constructor with types other than those that are required. For example, a **Point** constructor might take two integers. If you provided floats, this error is raised. +Visual Studio could not find a [constructor](/dotnet/csharp/programming-guide/classes-and-structs/constructors) that had matching parameters. This may be the result of supplying a constructor with types other than those that are required. For example, a **Point** constructor might take two integers. If you provided floats, this error is raised. To correct this error, use a different constructor or explicitly cast the parameter types such that they match those provided by the constructor. diff --git a/dotnet-desktop-guide/framework/winforms/controls/developing-a-composite-windows-forms-control.md b/dotnet-desktop-guide/framework/winforms/controls/developing-a-composite-windows-forms-control.md index 81df46cdf5..d029aa766e 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/developing-a-composite-windows-forms-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/developing-a-composite-windows-forms-control.md @@ -42,7 +42,7 @@ The Windows Forms designer in Visual Studio provides rich design-time support fo - [Walkthrough: Creating a Windows Forms Control That Takes Advantage of Visual Studio Design-Time Features](creating-a-wf-control-design-time-features.md) -- [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)) +- [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)) ## See also diff --git a/dotnet-desktop-guide/framework/winforms/controls/developing-custom-windows-forms-controls.md b/dotnet-desktop-guide/framework/winforms/controls/developing-custom-windows-forms-controls.md index 4493925d8a..5cbdc5a910 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/developing-custom-windows-forms-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/developing-custom-windows-forms-controls.md @@ -8,9 +8,11 @@ helpviewer_keywords: ms.assetid: 236cebc0-bd71-4f18-9fd6-5d0e592375df --- # Developing Custom Windows Forms Controls with the .NET Framework + Windows Forms controls are reusable components that encapsulate user interface functionality and are used in client-side Windows-based applications. Not only does Windows Forms provide many ready-to-use controls, it also provides the infrastructure for developing your own controls. You can combine existing controls, extend existing controls, or author your own custom controls. This section provides background information and samples to help you develop Windows Forms controls. ## In This Section + [Overview of Using Controls in Windows Forms](overview-of-using-controls-in-windows-forms.md) Highlights the essential elements of using controls in Windows Forms applications. @@ -39,6 +41,7 @@ Windows Forms controls are reusable components that encapsulate user interface f Shows how to implement multithreaded controls. ## Reference + Describes this class and has links to all of its members. @@ -46,13 +49,14 @@ Windows Forms controls are reusable components that encapsulate user interface f Describes this class and has links to all of its members. ## Related Sections - [Design-Time Attributes for Components](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/tk67c2t8(v=vs.120)) + + [Design-Time Attributes for Components](/previous-versions/visualstudio/visual-studio-2013/tk67c2t8(v=vs.120)) Lists metadata attributes to apply to components and controls so that they are displayed correctly at design time in visual designers. - [Extending Design-Time Support](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) + [Extending Design-Time Support](/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) Describes how to implement classes such as editors and designers that provide design-time support. - [How to: License Components and Controls](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/fe8b1eh9(v=vs.120)) + [How to: License Components and Controls](/previous-versions/visualstudio/visual-studio-2013/fe8b1eh9(v=vs.120)) Describes how to implement licensing in your control or component. Also see [Developing Windows Forms Controls at Design Time](developing-windows-forms-controls-at-design-time.md). diff --git a/dotnet-desktop-guide/framework/winforms/controls/developing-windows-forms-controls-at-design-time.md b/dotnet-desktop-guide/framework/winforms/controls/developing-windows-forms-controls-at-design-time.md index 70df82084d..e5e5fd2e4a 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/developing-windows-forms-controls-at-design-time.md +++ b/dotnet-desktop-guide/framework/winforms/controls/developing-windows-forms-controls-at-design-time.md @@ -18,9 +18,9 @@ manager: jillfra For control authors, the .NET Framework provides a wealth of control authoring technology. Authors are no longer limited to designing composite controls that act as a collection of preexisting controls. Through inheritance, you can create your own controls from preexisting composite controls or preexisting Windows Forms controls. You can also design your own controls that implement custom painting. These options enable a great deal of flexibility to the design and functionality of the visual interface. To take advantage of these features, you should be familiar with object-based programming concepts. > [!NOTE] -> It is not necessary to have a thorough understanding of inheritance, but you may find it useful to refer to [Inheritance basics (Visual Basic)](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/inheritance-basics). +> It is not necessary to have a thorough understanding of inheritance, but you may find it useful to refer to [Inheritance basics (Visual Basic)](/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/inheritance-basics). -If you want to create custom controls to use on Web Forms, see [Developing Custom ASP.NET Server Controls](https://docs.microsoft.com/previous-versions/aspnet/zt27tfhy(v=vs.100)). +If you want to create custom controls to use on Web Forms, see [Developing Custom ASP.NET Server Controls](/previous-versions/aspnet/zt27tfhy(v=vs.100)). ## In this section @@ -86,7 +86,7 @@ Shows how to diagnose and fix common issues that can occur when you author a cus [Developing Custom Windows Forms Controls with the .NET Framework](developing-custom-windows-forms-controls.md)\ Discusses how to create your own custom controls with the .NET Framework. -[Language Independence and Language-Independent Components](https://docs.microsoft.com/dotnet/standard/language-independence-and-language-independent-components)\ +[Language Independence and Language-Independent Components](/dotnet/standard/language-independence-and-language-independent-components)\ Introduces the common language runtime, which is designed to simplify the creation and use of components. An important aspect of this simplification is enhanced interoperability between components written using different programming languages. The Common Language Specification (CLS) makes it possible to create tools and components that work with multiple programming languages. [Walkthrough: Automatically Populating the Toolbox with Custom Components](walkthrough-automatically-populating-the-toolbox-with-custom-components.md)\ diff --git a/dotnet-desktop-guide/framework/winforms/controls/events-in-windows-forms-controls.md b/dotnet-desktop-guide/framework/winforms/controls/events-in-windows-forms-controls.md index 6e3a650a95..2ee0298fe3 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/events-in-windows-forms-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/events-in-windows-forms-controls.md @@ -7,13 +7,14 @@ helpviewer_keywords: ms.assetid: 7e3d1379-87aa-437c-afce-c99454eff30e --- # Events in Windows Forms Controls + A Windows Forms control inherits more than sixty events from . These include the event, which causes a control to be drawn, events related to displaying a window, such as the and events, and low-level mouse and keyboard events. Some low-level events are synthesized by into semantic events such as and . For details about inherited events, see . - If your custom control needs to override inherited event functionality, override the inherited `On`*EventName* method instead of attaching a delegate. If you are not familiar with the event model in the .NET Framework, see [Raising Events from a Component](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/sh2e3k5z(v=vs.120)). + If your custom control needs to override inherited event functionality, override the inherited `On`*EventName* method instead of attaching a delegate. If you are not familiar with the event model in the .NET Framework, see [Raising Events from a Component](/previous-versions/visualstudio/visual-studio-2013/sh2e3k5z(v=vs.120)). ## See also - [Overriding the OnPaint Method](overriding-the-onpaint-method.md) - [Handling User Input](handling-user-input.md) - [Defining an Event](defining-an-event-in-windows-forms-controls.md) -- [Events](https://docs.microsoft.com/dotnet/standard/events/index) +- [Events](/dotnet/standard/events/index) diff --git a/dotnet-desktop-guide/framework/winforms/controls/freeze-columns-in-the-datagrid-using-the-designer.md b/dotnet-desktop-guide/framework/winforms/controls/freeze-columns-in-the-datagrid-using-the-designer.md index 03daaf3826..b54ceac541 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/freeze-columns-in-the-datagrid-using-the-designer.md +++ b/dotnet-desktop-guide/framework/winforms/controls/freeze-columns-in-the-datagrid-using-the-designer.md @@ -9,6 +9,7 @@ helpviewer_keywords: ms.assetid: 87412dd2-478f-4751-af87-dafc591fc215 --- # How to: Freeze Columns in the Windows Forms DataGridView Control Using the Designer + When users view data displayed in a Windows Forms control, they sometimes need to refer to a single column or set of columns frequently. For example, when you display a table of customer information that contains many columns, it is useful for you to display the customer name at all times while enabling other columns to scroll outside the visible region. To achieve this behavior, you can freeze columns in the control. When you freeze a column, all the columns to its left (or to its right in right-to-left language scripts) are frozen as well. Frozen columns remain in place while all other columns can scroll. If column reordering is enabled, the frozen columns are treated as a group distinct from the unfrozen columns. Users can reposition columns in either group, but they cannot move a column from one group to the other. @@ -32,6 +33,6 @@ When users view data displayed in a Windows Forms - [How to: Add and Remove Columns in the Windows Forms DataGridView Control Using the Designer](add-and-remove-columns-in-the-datagrid-using-the-designer.md) - [How to: Enable Column Reordering in the Windows Forms DataGridView Control Using the Designer](enable-column-reordering-in-the-datagrid-using-the-designer.md) -- [How to: Display Right-to-Left Text in Windows Forms for Globalization](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/7d3337xw(v=vs.100)) +- [How to: Display Right-to-Left Text in Windows Forms for Globalization](/previous-versions/visualstudio/visual-studio-2010/7d3337xw(v=vs.100)) - [How to: Create a Windows Forms application project](/visualstudio/ide/step-1-create-a-windows-forms-application-project) - [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/handle-errors-that-occur-during-data-entry-in-the-datagrid.md b/dotnet-desktop-guide/framework/winforms/controls/handle-errors-that-occur-during-data-entry-in-the-datagrid.md index e85f2e2167..ae74383870 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/handle-errors-that-occur-during-data-entry-in-the-datagrid.md +++ b/dotnet-desktop-guide/framework/winforms/controls/handle-errors-that-occur-during-data-entry-in-the-datagrid.md @@ -13,21 +13,25 @@ helpviewer_keywords: ms.assetid: 9004e72f-fdec-4264-a37d-2c99764efc13 --- # How to: Handle Errors That Occur During Data Entry in the Windows Forms DataGridView Control + The following code example demonstrates how to use the control to report data entry errors to the user. For a complete explanation of this code example, see [Walkthrough: Handling Errors that Occur During Data Entry in the Windows Forms DataGridView Control](handling-errors-that-occur-during-data-entry-in-the-datagrid.md). ## Example + [!code-csharp[System.Windows.Forms.DataGridView.DataError#00](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DataError/CS/errorhandling.cs#00)] [!code-vb[System.Windows.Forms.DataGridView.DataError#00](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DataError/VB/errorhandling.vb#00)] ## Compiling the Code + This example requires: - References to the System, System.Data, System.Windows.Forms, and System.XML assemblies. ## .NET Framework Security - Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information). + + Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information). ## See also @@ -36,4 +40,4 @@ The following code example demonstrates how to use the object. Be sure that you set the `connectionString` variable to a value that is appropriate for your database. > [!IMPORTANT] - > Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information). + > Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information). [!code-csharp[System.Windows.Forms.DataGridView.DataError#30](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DataError/CS/errorhandling.cs#30)] [!code-vb[System.Windows.Forms.DataGridView.DataError#30](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DataError/VB/errorhandling.vb#30)] @@ -93,4 +93,4 @@ This application gives you a basic understanding of the . When handling an event, control authors should override the protected `On`*EventName* method rather than attaching a delegate to the event. For a review of events, see [Raising Events from a Component](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/sh2e3k5z(v=vs.120)). + +This topic describes the main keyboard and mouse events provided by . When handling an event, control authors should override the protected `On`*EventName* method rather than attaching a delegate to the event. For a review of events, see [Raising Events from a Component](/previous-versions/visualstudio/visual-studio-2013/sh2e3k5z(v=vs.120)). > [!NOTE] > If there is no data associated with an event, an instance of the base class is passed as an argument to the `On`*EventName* method. ## Keyboard Events + The common keyboard events that your control can handle are , , and . |Event Name|Method to Override|Description of Event| @@ -29,6 +31,7 @@ This topic describes the main keyboard and mouse events provided by Handling keyboard input is considerably more complex than overriding the events in the preceding table and is beyond the scope of this topic. For more information, see [User Input in Windows Forms](../user-input-in-windows-forms.md). ## Mouse Events + The mouse events that your control can handle are , , , , , and . |Event Name|Method to Override|Description of Event| @@ -61,5 +64,5 @@ This topic describes the main keyboard and mouse events provided by and properties on the control return the HTML of the current document as it existed when it was first displayed. However, if you modify the page using method and property calls such as and , these changes will not appear when you call and . To obtain the most up-to-date HTML source for the DOM, you must call the property on the HTML element. The following procedure shows how to retrieve the dynamic source and display it in a separate shortcut menu. @@ -29,7 +30,7 @@ The and control named `Button1` to your , and monitor for the event. For details on monitoring events, see [Events](https://docs.microsoft.com/dotnet/standard/events/index). +6. Add a control named `Button1` to your , and monitor for the event. For details on monitoring events, see [Events](/dotnet/standard/events/index). 7. Add the following code to the event handler. @@ -37,6 +38,7 @@ The and before attempting to retrieve it. If the current page is not finished loading, or one or more of its child objects may not be initialized. ## See also diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-access-the-managed-html-document-object-model.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-access-the-managed-html-document-object-model.md index 5ffa45c0b4..95e46e868e 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-access-the-managed-html-document-object-model.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-access-the-managed-html-document-object-model.md @@ -10,6 +10,7 @@ helpviewer_keywords: ms.assetid: 40fa5cd5-1ed8-42f6-a93f-9ac01608bbeb --- # How to: Access the Managed HTML Document Object Model + You can access the managed HTML Document Object Model (DOM) from two types of applications: - A Windows Forms application (.exe) that hosted the managed control. These two technologies complement one another, with the control displaying the page to the user and the HTML DOM representing the document's logical structure. @@ -18,7 +19,7 @@ You can access the managed HTML Document Object Model (DOM) from two types of ap ### To access DOM from a Windows Forms application -1. Host a control within your Windows Forms application and monitor for the event. For details on hosting controls and monitoring for events, see [Events](https://docs.microsoft.com/dotnet/standard/events/index). +1. Host a control within your Windows Forms application and monitor for the event. For details on hosting controls and monitoring for events, see [Events](/dotnet/standard/events/index). 2. Retrieve the for the current page by accessing the property of the control. diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-activex-controls-to-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-activex-controls-to-windows-forms.md index a8b6d26b13..a3b0a407d4 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-activex-controls-to-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-activex-controls-to-windows-forms.md @@ -14,7 +14,7 @@ While the Windows Forms Designer in Visual Studio is optimized to host Windows F > [!CAUTION] > There are performance limitations for Windows Forms when ActiveX controls are added to them. -Before you add ActiveX controls to your form, you must add them to the Toolbox. For more information, see [COM Components, Customize Toolbox Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/cby6tzh5(v=vs.100)). +Before you add ActiveX controls to your form, you must add them to the Toolbox. For more information, see [COM Components, Customize Toolbox Dialog Box](/previous-versions/visualstudio/visual-studio-2010/cby6tzh5(v=vs.100)). ## Add an ActiveX control to your Windows Form @@ -23,12 +23,12 @@ To add an ActiveX control to your Windows Form, double-click the control on the Visual Studio adds all references to the control in your project. For more information about things to keep in mind when using ActiveX controls on Windows Forms, see [Considerations When Hosting an ActiveX Control on a Windows Form](considerations-when-hosting-an-activex-control-on-a-windows-form.md). > [!NOTE] -> The Windows Forms ActiveX Control Importer (AxImp.exe) creates event arguments of a different type than expected upon importation of ActiveX dynamic link libraries. The arguments created by AxImp.exe are similar to the following: `Invoke(object sender, DWebBrowserEvents2_ProgressChangeEvent e)`, when `Invoke(object sender, DWebBrowserEvents2_ProgressChangeEventArgs e)` is expected. Be aware that this irregularity does not prevent code from functioning normally. For details, see [Windows Forms ActiveX Control Importer (Aximp.exe)](https://docs.microsoft.com/dotnet/framework/tools/aximp-exe-windows-forms-activex-control-importer). +> The Windows Forms ActiveX Control Importer (AxImp.exe) creates event arguments of a different type than expected upon importation of ActiveX dynamic link libraries. The arguments created by AxImp.exe are similar to the following: `Invoke(object sender, DWebBrowserEvents2_ProgressChangeEvent e)`, when `Invoke(object sender, DWebBrowserEvents2_ProgressChangeEventArgs e)` is expected. Be aware that this irregularity does not prevent code from functioning normally. For details, see [Windows Forms ActiveX Control Importer (Aximp.exe)](/dotnet/framework/tools/aximp-exe-windows-forms-activex-control-importer). ## See also - [Windows Forms Controls](index.md) -- [Controls and Programmable Objects Compared in Various Languages and Libraries](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/0061wezk(v=vs.100)) +- [Controls and Programmable Objects Compared in Various Languages and Libraries](/previous-versions/visualstudio/visual-studio-2010/0061wezk(v=vs.100)) - [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md) - [Labeling Individual Windows Forms Controls and Providing Shortcuts to Them](labeling-individual-windows-forms-controls-and-providing-shortcuts-to-them.md) - [Controls to Use on Windows Forms](controls-to-use-on-windows-forms.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-controls-to-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-controls-to-windows-forms.md index 6fe24856e6..f8cafb7e1b 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-controls-to-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-controls-to-windows-forms.md @@ -17,7 +17,7 @@ Most forms are designed by adding controls to the surface of the form to define ## To draw a control on a form -1. Open the form. For more information, see [How to: Display Windows Forms in the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/w5yd62ts(v=vs.100)). +1. Open the form. For more information, see [How to: Display Windows Forms in the Designer](/previous-versions/visualstudio/visual-studio-2010/w5yd62ts(v=vs.100)). 2. In the **Toolbox**, click the control you want to add to your form. @@ -30,7 +30,7 @@ Most forms are designed by adding controls to the surface of the form to define ## To drag a control to a form -1. Open the form. For more information, see [How to: Display Windows Forms in the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/w5yd62ts(v=vs.100)). +1. Open the form. For more information, see [How to: Display Windows Forms in the Designer](/previous-versions/visualstudio/visual-studio-2010/w5yd62ts(v=vs.100)). 2. In the **Toolbox**, click the control you want and drag it to your form. @@ -78,7 +78,6 @@ Most forms are designed by adding controls to the surface of the form to define > [!NOTE] > You can also add code to initialize other properties of the control. - > [!IMPORTANT] > You might expose your local computer to a security risk through the network by referencing a malicious `UserControl`. This would only be a concern in the case of a malicious person creating a damaging custom control, followed by you mistakenly adding it to your project. diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-controls-without-a-user-interface-to-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-controls-without-a-user-interface-to-windows-forms.md index ea8839b0fe..eed4b3138f 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-controls-without-a-user-interface-to-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-controls-without-a-user-interface-to-windows-forms.md @@ -21,13 +21,13 @@ A nonvisual control (or component) provides functionality to your application. U ## Add a component to a Windows Form -1. Open the form in Visual Studio. For details, see [How to: Display Windows Forms in the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/w5yd62ts(v=vs.100)). +1. Open the form in Visual Studio. For details, see [How to: Display Windows Forms in the Designer](/previous-versions/visualstudio/visual-studio-2010/w5yd62ts(v=vs.100)). 2. In the **Toolbox**, click a component and drag it to your form. Your component appears in the component tray. -Furthermore, components can be added to a form at run time. This is a common scenario, especially because components do not have a visual expression, unlike controls that have a user interface. In the example below, a component is added at run time. (Note that Visual Studio contains a number of different timers; in this case, use a Windows Forms component. For more information about the different timers in Visual Studio, see [Introduction to Server-Based Timers](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)).) +Furthermore, components can be added to a form at run time. This is a common scenario, especially because components do not have a visual expression, unlike controls that have a user interface. In the example below, a component is added at run time. (Note that Visual Studio contains a number of different timers; in this case, use a Windows Forms component. For more information about the different timers in Visual Studio, see [Introduction to Server-Based Timers](/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)).) > [!CAUTION] > Components often have control-specific properties that must be set for the component to function effectively. In the case of the component below, you set the `Interval` property. Be sure, when adding components to your project, that you set the properties necessary for that component. diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-panels-to-a-statusbar-control.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-panels-to-a-statusbar-control.md index 10a1584fc3..bcfa5ca600 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-panels-to-a-statusbar-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-panels-to-a-statusbar-control.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: 835e3902-288c-4c38-9d69-0696d8695009 --- # How to: Add Panels to a StatusBar Control + > [!IMPORTANT] > The and controls replace and add functionality to the and controls; however, the and controls are retained for both backward compatibility and future use, if you choose. @@ -118,7 +119,7 @@ ms.assetid: 835e3902-288c-4c38-9d69-0696d8695009 - - -- [Collection Editor Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/xc4yyekt(v=vs.100)) +- [Collection Editor Dialog Box](/previous-versions/visualstudio/visual-studio-2010/xc4yyekt(v=vs.100)) - [How to: Set the Size of Status-Bar Panels](how-to-set-the-size-of-status-bar-panels.md) - [Walkthrough: Updating Status Bar Information at Run Time](walkthrough-updating-status-bar-information-at-run-time.md) - [How to: Determine Which Panel in the Windows Forms StatusBar Control Was Clicked](determine-which-panel-wf-statusbar-control-was-clicked.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-to-or-remove-from-a-collection-of-controls-at-run-time.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-to-or-remove-from-a-collection-of-controls-at-run-time.md index 58b0c2bdc6..0909051651 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-add-to-or-remove-from-a-collection-of-controls-at-run-time.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-add-to-or-remove-from-a-collection-of-controls-at-run-time.md @@ -15,6 +15,7 @@ helpviewer_keywords: ms.assetid: 771bf895-3d5f-469b-a324-3528f343657e --- # How to: Add to or Remove from a Collection of Controls at Run Time + Common tasks in application development are adding controls to and removing controls from any container control on your forms (such as the or control, or even the form itself). At design time, controls can be dragged directly onto a panel or group box. At run time, these controls maintain a `Controls` collection, which keeps track of what controls are placed on them. > [!NOTE] @@ -61,7 +62,7 @@ Common tasks in application development are adding controls to and removing cont ### To remove controls from a collection programmatically -1. Remove the event handler from the event. In Visual Basic, use the [RemoveHandler Statement](https://docs.microsoft.com/dotnet/visual-basic/language-reference/statements/removehandler-statement) keyword; in C#, use the [-= operator](https://docs.microsoft.com/dotnet/csharp/language-reference/operators/subtraction-operator). +1. Remove the event handler from the event. In Visual Basic, use the [RemoveHandler Statement](/dotnet/visual-basic/language-reference/statements/removehandler-statement) keyword; in C#, use the [-= operator](/dotnet/csharp/language-reference/operators/subtraction-operator). 2. Use the `Remove` method to delete the desired control from the panel's `Controls` collection. diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-apply-attributes-in-windows-forms-controls.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-apply-attributes-in-windows-forms-controls.md index 8ce32035a1..d36d0a6f31 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-apply-attributes-in-windows-forms-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-apply-attributes-in-windows-forms-controls.md @@ -11,9 +11,11 @@ helpviewer_keywords: ms.assetid: af0a3f7f-155b-4ba1-83c4-9cf721331a06 --- # How to: Apply Attributes in Windows Forms Controls + To develop components and controls that interact correctly with the design environment and execute correctly at run time, you need to apply attributes correctly to classes and members. ## Example + The following code example demonstrates how to use several attributes on a custom control. The control demonstrates a simple logging capability. When the control is bound to a data source, it displays the values sent by the data source in a control. If a value exceeds the value specified by the `Threshold` property, a `ThresholdExceeded` event is raised. The `AttributesDemoControl` logs values with a `LogEntry` class. The `LogEntry` class is a template class, which means it is parameterized on the type that it logs. For example, if the `AttributesDemoControl` is logging values of type `float`, each `LogEntry` instance is declared and used as follows. @@ -35,30 +37,35 @@ To develop components and controls that interact correctly with the design envir The first code example is the `AttributesDemoControl` implementation. The second code example demonstrates a form that uses the `AttributesDemoControl`. ## Class-level Attributes + Some attributes are applied at the class level. The following code example shows the attributes that are commonly applied to a Windows Forms control. [!code-csharp[System.ComponentModel.AttributesDemoControl#20](~/samples/snippets/csharp/VS_Snippets_Winforms/System.ComponentModel.AttributesDemoControl/CS/attributesdemocontrol.cs#20)] [!code-vb[System.ComponentModel.AttributesDemoControl#20](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.ComponentModel.AttributesDemoControl/VB/attributesdemocontrol.vb#20)] ### TypeConverter Attribute + is another commonly used class-level attribute. The following code example shows its use for the `LogEntry` class. This example also shows an implementation of a for the `LogEntry` type, called `LogEntryTypeConverter`. [!code-csharp[System.ComponentModel.AttributesDemoControl#5](~/samples/snippets/csharp/VS_Snippets_Winforms/System.ComponentModel.AttributesDemoControl/CS/attributesdemocontrol.cs#5)] [!code-vb[System.ComponentModel.AttributesDemoControl#5](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.ComponentModel.AttributesDemoControl/VB/attributesdemocontrol.vb#5)] ## Member-level Attributes + Some attributes are applied at the member level. The following code examples show some attributes that are commonly applied to properties of Windows Forms controls. [!code-csharp[System.ComponentModel.AttributesDemoControl#21](~/samples/snippets/csharp/VS_Snippets_Winforms/System.ComponentModel.AttributesDemoControl/CS/attributesdemocontrol.cs#21)] [!code-vb[System.ComponentModel.AttributesDemoControl#21](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.ComponentModel.AttributesDemoControl/VB/attributesdemocontrol.vb#21)] ### AmbientValue Attribute + The following example demonstrates the and shows code that supports its interaction with the design environment. This interaction is called *ambience*. [!code-csharp[System.ComponentModel.AttributesDemoControl#23](~/samples/snippets/csharp/VS_Snippets_Winforms/System.ComponentModel.AttributesDemoControl/CS/attributesdemocontrol.cs#23)] [!code-vb[System.ComponentModel.AttributesDemoControl#23](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.ComponentModel.AttributesDemoControl/VB/attributesdemocontrol.vb#23)] ### Databinding Attributes + The following examples demonstrate an implementation of complex data binding. The class-level , shown previously, specifies the `DataSource` and `DataMember` properties to use for data binding. The specifies the type to which the `DataSource` property will bind. [!code-csharp[System.ComponentModel.AttributesDemoControl#25](~/samples/snippets/csharp/VS_Snippets_Winforms/System.ComponentModel.AttributesDemoControl/CS/attributesdemocontrol.cs#25)] @@ -77,4 +84,4 @@ To develop components and controls that interact correctly with the design envir - - [Developing Custom Windows Forms Controls with the .NET Framework](developing-custom-windows-forms-controls.md) - [Attributes in Windows Forms Controls](attributes-in-windows-forms-controls.md) -- [How to: Serialize Collections of Standard Types with the DesignerSerializationVisibilityAttribute](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/ms171833(v=vs.120)) +- [How to: Serialize Collections of Standard Types with the DesignerSerializationVisibilityAttribute](/previous-versions/visualstudio/visual-studio-2013/ms171833(v=vs.120)) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-bind-data-to-the-windows-forms-datagridview-control.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-bind-data-to-the-windows-forms-datagridview-control.md index 2c9670dfc5..9a9e1a440a 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-bind-data-to-the-windows-forms-datagridview-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-bind-data-to-the-windows-forms-datagridview-control.md @@ -29,13 +29,13 @@ This complete code example retrieves data from a database to populate a DataGrid This example requires: -- Access to a Northwind SQL Server sample database. For more information about installing the Northwind sample database, see [Get the sample databases for ADO.NET code samples](https://docs.microsoft.com/dotnet/framework/data/adonet/sql/linq/downloading-sample-databases). +- Access to a Northwind SQL Server sample database. For more information about installing the Northwind sample database, see [Get the sample databases for ADO.NET code samples](/dotnet/framework/data/adonet/sql/linq/downloading-sample-databases). - References to the System, System.Windows.Forms, System.Data, and System.Xml assemblies. -To build and run this example, paste the code into the *Form1* code file in a new Windows Forms project. For information about building from the C# or Visual Basic command line, see [Command-line building with csc.exe](https://docs.microsoft.com/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe) or [Build from the command line](https://docs.microsoft.com/dotnet/visual-basic/reference/command-line-compiler/building-from-the-command-line). +To build and run this example, paste the code into the *Form1* code file in a new Windows Forms project. For information about building from the C# or Visual Basic command line, see [Command-line building with csc.exe](/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe) or [Build from the command line](/dotnet/visual-basic/reference/command-line-compiler/building-from-the-command-line). -Populate the `connectionString` variable in the example with the values for your Northwind SQL Server sample database connection. Windows Authentication, also called integrated security, is a more secure way to connect to the database than storing a password in the connection string. For more information about connection security, see [Protect connection information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information). +Populate the `connectionString` variable in the example with the values for your Northwind SQL Server sample database connection. Windows Authentication, also called integrated security, is a more secure way to connect to the database than storing a password in the connection string. For more information about connection security, see [Protect connection information](/dotnet/framework/data/adonet/protecting-connection-information). [!code-csharp[System.Windows.Forms.DataGridViewBoundEditable](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewBoundEditable/CS/datagridviewboundeditable.cs)] [!code-vb[System.Windows.Forms.DataGridViewBoundEditable](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewBoundEditable/VB/datagridviewboundeditable.vb)] @@ -46,4 +46,4 @@ Populate the `connectionString` variable in the example with the values for your - - - [Display data in the Windows Forms DataGridView control](displaying-data-in-the-windows-forms-datagridview-control.md) -- [Protect connection information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information) +- [Protect connection information](/dotnet/framework/data/adonet/protecting-connection-information) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-choose-folders-with-the-windows-forms-folderbrowserdialog-component.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-choose-folders-with-the-windows-forms-folderbrowserdialog-component.md index d44c890a00..57597fcfb9 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-choose-folders-with-the-windows-forms-folderbrowserdialog-component.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-choose-folders-with-the-windows-forms-folderbrowserdialog-component.md @@ -58,7 +58,7 @@ Often, within Windows applications you create, you will have to prompt users to ``` > [!IMPORTANT] - > To use this class, your assembly requires a privilege level granted by the property, which is part of the enumeration. If you are running in a partial-trust context, the process might throw an exception because of insufficient privileges. For more information, see [Code Access Security Basics](https://docs.microsoft.com/dotnet/framework/misc/code-access-security-basics). + > To use this class, your assembly requires a privilege level granted by the property, which is part of the enumeration. If you are running in a partial-trust context, the process might throw an exception because of insufficient privileges. For more information, see [Code Access Security Basics](/dotnet/framework/misc/code-access-security-basics). For information on how to save files, see [How to: Save Files Using the SaveFileDialog Component](how-to-save-files-using-the-savefiledialog-component.md). diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-create-a-resizable-windows-form-for-data-entry.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-create-a-resizable-windows-form-for-data-entry.md index 1cb45c9ccb..0dfc765e7e 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-create-a-resizable-windows-form-for-data-entry.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-create-a-resizable-windows-form-for-data-entry.md @@ -13,9 +13,11 @@ helpviewer_keywords: ms.assetid: babdf198-404c-485d-a914-ed370c6ecd99 --- # How to: Create a Resizable Windows Form for Data Entry -A good layout responds well to changes in the dimensions of its parent form. You can use the control to arrange the layout of your form to resize and position your controls in a consistent way as the form's dimensions change. The control is also useful when changes in the contents of your controls cause changes in the layout. The process covered in this procedure can be done within the Visual Studio environment. Also see [Walkthrough: Creating a Resizable Windows Form for Data Entry](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/991eahec(v=vs.100)). + +A good layout responds well to changes in the dimensions of its parent form. You can use the control to arrange the layout of your form to resize and position your controls in a consistent way as the form's dimensions change. The control is also useful when changes in the contents of your controls cause changes in the layout. The process covered in this procedure can be done within the Visual Studio environment. Also see [Walkthrough: Creating a Resizable Windows Form for Data Entry](/previous-versions/visualstudio/visual-studio-2010/991eahec(v=vs.100)). ## Example + The following example demonstrates how to use a control to build a layout that responds well when the user resizes the form. It also demonstrates a layout that responds well to localization. [!code-cpp[System.Windows.Forms.TableLayoutPanel.DataEntryForm#1](~/samples/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel.DataEntryForm/cpp/basicdataentryform.cpp#1)] @@ -23,6 +25,7 @@ A good layout responds well to changes in the dimensions of its parent form. You [!code-vb[System.Windows.Forms.TableLayoutPanel.DataEntryForm#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel.DataEntryForm/VB/basicdataentryform.vb#1)] ## Compiling the Code + This example requires: - References to the System, System.Data, System.Drawing and System.Windows.Forms assemblies. diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-create-a-windows-forms-control-that-shows-progress.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-create-a-windows-forms-control-that-shows-progress.md index e192599c6f..8e7ffc8d5b 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-create-a-windows-forms-control-that-shows-progress.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-create-a-windows-forms-control-that-shows-progress.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: 24c5a2e3-058c-4b8d-a217-c06e6a130c2f --- # How to: Create a Windows Forms Control That Shows Progress + The following code example shows a custom control called `FlashTrackBar` that can be used to show the user the level or the progress of an application. It uses a gradient to visually represent progress. The `FlashTrackBar` control illustrates the following concepts: @@ -72,6 +73,7 @@ The following code example shows a custom control called `FlashTrackBar` that ca - ## Example + The `FlashTrackBar` control defines two UI type editors, `FlashTrackBarValueEditor` and `FlashTrackBarDarkenByEditor`, which are shown in the following code listings. The `HostApp` class uses the `FlashTrackBar` control on a Windows Form. [!code-csharp[System.Windows.Forms.FlashTrackBar#1](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.FlashTrackBar/CS/FlashTrackBar.cs#1)] @@ -88,5 +90,5 @@ The following code example shows a custom control called `FlashTrackBar` that ca ## See also -- [Extending Design-Time Support](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) +- [Extending Design-Time Support](/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) - [Windows Forms Control Development Basics](windows-forms-control-development-basics.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-design-a-windows-forms-layout-that-responds-well-to-localization.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-design-a-windows-forms-layout-that-responds-well-to-localization.md index b67551464d..86c4ef5502 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-design-a-windows-forms-layout-that-responds-well-to-localization.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-design-a-windows-forms-layout-that-responds-well-to-localization.md @@ -12,12 +12,14 @@ helpviewer_keywords: ms.assetid: d13eff2d-701c-4b6e-8838-3885cbfb7223 --- # How to: Design a Windows Forms Layout that Responds Well to Localization + Creating forms that are ready to be localized greatly speeds development for international markets. You can use the control to implement layouts that respond gracefully as controls resize due to changes in their property values. ## Example - This form demonstrates how to create a layout that proportionally adjusts when you translate displayed string values into other languages. This process of translation is called *localization*. For more information, see [Localization](https://docs.microsoft.com/dotnet/standard/globalization-localization/localization). - There is extensive support for this task in Visual Studio. See also [Walkthrough: Creating a Layout That Adjusts Proportion for Localization](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100)). + This form demonstrates how to create a layout that proportionally adjusts when you translate displayed string values into other languages. This process of translation is called *localization*. For more information, see [Localization](/dotnet/standard/globalization-localization/localization). + + There is extensive support for this task in Visual Studio. See also [Walkthrough: Creating a Layout That Adjusts Proportion for Localization](/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100)). [!code-csharp[System.Windows.Forms.TableLayoutPanel.LocalizableForm#1](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel.LocalizableForm/CS/localizableform.cs#1)] [!code-vb[System.Windows.Forms.TableLayoutPanel.LocalizableForm#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel.LocalizableForm/VB/localizableform.vb#1)] @@ -38,11 +40,12 @@ Creating forms that are ready to be localized greatly speeds development for int 7. [Walkthrough: Laying Out Windows Forms Controls with Padding, Margins, and the AutoSize Property](windows-forms-controls-padding-autosize.md) -8. [How to: Support Localization on Windows Forms Using AutoSize and the TableLayoutPanel Control](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/1zkt8b33(v=vs.100)) +8. [How to: Support Localization on Windows Forms Using AutoSize and the TableLayoutPanel Control](/previous-versions/visualstudio/visual-studio-2010/1zkt8b33(v=vs.100)) -9. [Walkthrough: Creating a Resizable Windows Form for Data Entry](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/991eahec(v=vs.100)) +9. [Walkthrough: Creating a Resizable Windows Form for Data Entry](/previous-versions/visualstudio/visual-studio-2010/991eahec(v=vs.100)) ## Compiling the Code + This example requires: - References to the System, System.Data, System.Drawing and System.Windows.Forms assemblies. @@ -51,4 +54,4 @@ Creating forms that are ready to be localized greatly speeds development for int - - -- [Localization](https://docs.microsoft.com/dotnet/standard/globalization-localization/localization) +- [Localization](/dotnet/standard/globalization-localization/localization) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-develop-a-simple-windows-forms-control.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-develop-a-simple-windows-forms-control.md index 5e6121e422..306959ef55 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-develop-a-simple-windows-forms-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-develop-a-simple-windows-forms-control.md @@ -29,7 +29,7 @@ This section walks you through the key steps for authoring a custom Windows Form public class FirstControl:Control {} ``` -2. Define properties. (You are not required to define properties, because a control inherits many properties from the class, but most custom controls generally do define additional properties.) The following code fragment defines a property named `TextAlignment` that `FirstControl` uses to format the display of the property inherited from . For more information about defining properties, see [Properties Overview](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/65zdfbdt(v%3dvs.120)). +2. Define properties. (You are not required to define properties, because a control inherits many properties from the class, but most custom controls generally do define additional properties.) The following code fragment defines a property named `TextAlignment` that `FirstControl` uses to format the display of the property inherited from . For more information about defining properties, see [Properties Overview](/previous-versions/visualstudio/visual-studio-2013/65zdfbdt(v%3dvs.120)). [!code-csharp[System.Windows.Forms.FirstControl#3](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.FirstControl/CS/FirstControl.cs#3)] [!code-vb[System.Windows.Forms.FirstControl#3](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FirstControl/VB/FirstControl.vb#3)] @@ -41,12 +41,12 @@ This section walks you through the key steps for authoring a custom Windows Form [!code-csharp[System.Windows.Forms.FirstControl#4](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.FirstControl/CS/FirstControl.cs#4)] [!code-vb[System.Windows.Forms.FirstControl#4](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FirstControl/VB/FirstControl.vb#4)] -4. Provide attributes for your control. Attributes enable a visual designer to display your control and its properties and events appropriately at design time. The following code fragment applies attributes to the `TextAlignment` property. In a designer such as Visual Studio, the attribute (shown in the code fragment) causes the property to be displayed under a logical category. The attribute causes a descriptive string to be displayed at the bottom of the **Properties** window when the `TextAlignment` property is selected. For more information about attributes, see [Design-Time Attributes for Components](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/tk67c2t8(v=vs.120)). +4. Provide attributes for your control. Attributes enable a visual designer to display your control and its properties and events appropriately at design time. The following code fragment applies attributes to the `TextAlignment` property. In a designer such as Visual Studio, the attribute (shown in the code fragment) causes the property to be displayed under a logical category. The attribute causes a descriptive string to be displayed at the bottom of the **Properties** window when the `TextAlignment` property is selected. For more information about attributes, see [Design-Time Attributes for Components](/previous-versions/visualstudio/visual-studio-2013/tk67c2t8(v=vs.120)). [!code-csharp[System.Windows.Forms.FirstControl#5](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.FirstControl/CS/FirstControl.cs#5)] [!code-vb[System.Windows.Forms.FirstControl#5](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FirstControl/VB/FirstControl.vb#5)] -5. (optional) Provide resources for your control. You can provide a resource, such as a bitmap, for your control by using a compiler option (`/res` for C#) to package resources with your control. At run time, the resource can be retrieved using the methods of the class. For more information about creating and using resources, see the [Resources in Desktop Apps](https://docs.microsoft.com/dotnet/framework/resources/index). +5. (optional) Provide resources for your control. You can provide a resource, such as a bitmap, for your control by using a compiler option (`/res` for C#) to package resources with your control. At run time, the resource can be retrieved using the methods of the class. For more information about creating and using resources, see the [Resources in Desktop Apps](/dotnet/framework/resources/index). 6. Compile and deploy your control. To compile and deploy `FirstControl,` execute the following steps: @@ -62,7 +62,7 @@ This section walks you through the key steps for authoring a custom Windows Form csc -t:library -out:[path to your application's directory]/CustomWinControls.dll -r:System.dll -r:System.Windows.Forms.dll -r:System.Drawing.dll FirstControl.cs ``` - The `/t:library` compiler option tells the compiler that the assembly you are creating is a library (and not an executable). The `/out` option specifies the path and name of the assembly. The`/r` option provides the name of the assemblies that are referenced by your code. In this example, you create a private assembly that only your applications can use. Hence, you have to save it in your application's directory. For more information about packaging and deploying a control for distribution, see [Deployment](https://docs.microsoft.com/dotnet/framework/deployment/index). + The `/t:library` compiler option tells the compiler that the assembly you are creating is a library (and not an executable). The `/out` option specifies the path and name of the assembly. The`/r` option provides the name of the assemblies that are referenced by your code. In this example, you create a private assembly that only your applications can use. Hence, you have to save it in your application's directory. For more information about packaging and deploying a control for distribution, see [Deployment](/dotnet/framework/deployment/index). The following sample shows the code for `FirstControl`. The control is enclosed in the namespace `CustomWinControls`. A namespace provides a logical grouping of related types. You can create your control in a new or existing namespace. In C#, the `using` declaration (in Visual Basic, `Imports`) allows types to be accessed from a namespace without using the fully qualified name of the type. In the following example, the `using` declaration allows code to access the class from as simply instead of having to use the fully qualified name . diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-display-a-control-in-the-choose-toolbox-items-dialog-box.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-display-a-control-in-the-choose-toolbox-items-dialog-box.md index 824ee2de80..0d3d9685b3 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-display-a-control-in-the-choose-toolbox-items-dialog-box.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-display-a-control-in-the-choose-toolbox-items-dialog-box.md @@ -18,7 +18,7 @@ As you develop and distribute controls, you may want those controls to appear in To display your control in the Choose Toolbox Items dialog box: -- Install your control assembly to the global assembly cache. For more information, see [How to: Install an Assembly into the Global Assembly Cache](https://docs.microsoft.com/dotnet/framework/app-domains/install-assembly-into-gac). +- Install your control assembly to the global assembly cache. For more information, see [How to: Install an Assembly into the Global Assembly Cache](/dotnet/framework/app-domains/install-assembly-into-gac). -or- @@ -27,5 +27,5 @@ To display your control in the Choose Toolbox Items dialog box: ## See also - [Developing Windows Forms Controls at Design Time](developing-windows-forms-controls-at-design-time.md) -- [How to: Install an Assembly into the Global Assembly Cache](https://docs.microsoft.com/dotnet/framework/app-domains/install-assembly-into-gac) +- [How to: Install an Assembly into the Global Assembly Cache](/dotnet/framework/app-domains/install-assembly-into-gac) - [Walkthrough: Automatically Populating the Toolbox with Custom Components](walkthrough-automatically-populating-the-toolbox-with-custom-components.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-display-web-style-links-with-the-windows-forms-richtextbox-control.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-display-web-style-links-with-the-windows-forms-richtextbox-control.md index 3069253a03..1db02361d2 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-display-web-style-links-with-the-windows-forms-richtextbox-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-display-web-style-links-with-the-windows-forms-richtextbox-control.md @@ -28,7 +28,7 @@ The Windows Forms control can display We In the example below, the event opens an instance of Internet Explorer to the URL specified in the property of the control. This example assumes a form with a control. > [!IMPORTANT] - > In calling the method, you will encounter a exception if you are running the code in a partial-trust context because of insufficient privileges. For more information, see [Code Access Security Basics](https://docs.microsoft.com/dotnet/framework/misc/code-access-security-basics). + > In calling the method, you will encounter a exception if you are running the code in a partial-trust context because of insufficient privileges. For more information, see [Code Access Security Basics](/dotnet/framework/misc/code-access-security-basics). ```vb Public p As New System.Diagnostics.Process diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control.md index 331dd0a55d..bdd55ed7e8 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control.md @@ -18,11 +18,12 @@ helpviewer_keywords: ms.assetid: 8c33543c-9c08-4636-a65a-fdf714a529b7 --- # How to: Format Data in the Windows Forms DataGridView Control + The following procedures demonstrate basic formatting of cell values using the property of a control and of specific columns in a control. For information about advanced data formatting, see [How to: Customize Data Formatting in the Windows Forms DataGridView Control](how-to-customize-data-formatting-in-the-windows-forms-datagridview-control.md). ### To format currency and date values -- Set the property of a . The following code example sets the format for specific columns using the property of the columns. Values in the `UnitPrice` column appear in the current culture-specific currency format, with negative values surrounded by parentheses. Values in the `ShipDate` column appear in the current culture-specific short date format. For more information about values, see [Formatting Types](https://docs.microsoft.com/dotnet/standard/base-types/formatting-types). +- Set the property of a . The following code example sets the format for specific columns using the property of the columns. Values in the `UnitPrice` column appear in the current culture-specific currency format, with negative values surrounded by parentheses. Values in the `ShipDate` column appear in the current culture-specific short date format. For more information about values, see [Formatting Types](/dotnet/standard/base-types/formatting-types). [!code-csharp[System.Windows.Forms.DataGridViewMisc#071](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/CS/datagridviewmisc.cs#071)] [!code-vb[System.Windows.Forms.DataGridViewMisc#071](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb#071)] @@ -49,10 +50,12 @@ The following procedures demonstrate basic formatting of cell values using the < [!code-vb[System.Windows.Forms.DataGridViewMisc#072](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb#072)] ## Example + [!code-csharp[System.Windows.Forms.DataGridViewMisc#070](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/CS/datagridviewmisc.cs#070)] [!code-vb[System.Windows.Forms.DataGridViewMisc#070](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb#070)] ## Compiling the Code + These examples require: - A control named `dataGridView1` that contains a column named `UnitPrice`, a column named `ShipDate`, and a column named `CustomerName`. @@ -60,6 +63,7 @@ The following procedures demonstrate basic formatting of cell values using the < - References to the , , and assemblies. ## Robust Programming + For maximum scalability, you should share objects across multiple rows, columns, or cells that use the same styles rather than setting the style properties for each element separately. For more information, see [Best Practices for Scaling the Windows Forms DataGridView Control](best-practices-for-scaling-the-windows-forms-datagridview-control.md). ## See also @@ -71,4 +75,4 @@ The following procedures demonstrate basic formatting of cell values using the < - [Cell Styles in the Windows Forms DataGridView Control](cell-styles-in-the-windows-forms-datagridview-control.md) - [Data Formatting in the Windows Forms DataGridView Control](data-formatting-in-the-windows-forms-datagridview-control.md) - [How to: Customize Data Formatting in the Windows Forms DataGridView Control](how-to-customize-data-formatting-in-the-windows-forms-datagridview-control.md) -- [Formatting Types](https://docs.microsoft.com/dotnet/standard/base-types/formatting-types) +- [Formatting Types](/dotnet/standard/base-types/formatting-types) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-format-the-windows-forms-datagrid-control-using-the-designer.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-format-the-windows-forms-datagrid-control-using-the-designer.md index 9880f0ae36..fbb58106b5 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-format-the-windows-forms-datagrid-control-using-the-designer.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-format-the-windows-forms-datagrid-control-using-the-designer.md @@ -27,7 +27,7 @@ There are three basic aspects of formatting the itself. These color and format choices form a base from which you can then make changes depending on the data tables and columns displayed. -The following procedure requires a **Windows Application** project with a form containing a control. For information about setting up such a project, see [How to: Create a Windows Forms application project](/visualstudio/ide/step-1-create-a-windows-forms-application-project) and [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md). In Visual Studio 2005, the control is not in the **Toolbox** by default. For more information, see [How to: Add Items to the Toolbox](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms165355(v=vs.100)). +The following procedure requires a **Windows Application** project with a form containing a control. For information about setting up such a project, see [How to: Create a Windows Forms application project](/visualstudio/ide/step-1-create-a-windows-forms-application-project) and [How to: Add Controls to Windows Forms](how-to-add-controls-to-windows-forms.md). In Visual Studio 2005, the control is not in the **Toolbox** by default. For more information, see [How to: Add Items to the Toolbox](/previous-versions/visualstudio/visual-studio-2010/ms165355(v=vs.100)). ### To establish a default style for the DataGrid control @@ -87,7 +87,7 @@ The following procedure requires a **Windows Application** project with a form c With the **DataGridColumnStyle Collection Editor**, you can add and remove column styles, set display and layout properties, and set the mapping name and formatting strings for the data columns. > [!NOTE] - > For more information about formatting strings, see [Formatting Types](https://docs.microsoft.com/dotnet/standard/base-types/formatting-types). + > For more information about formatting strings, see [Formatting Types](/dotnet/standard/base-types/formatting-types). ## See also diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-implement-a-form-that-uses-a-background-operation.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-implement-a-form-that-uses-a-background-operation.md index 5e4ca264fb..7c0e787c7e 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-implement-a-form-that-uses-a-background-operation.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-implement-a-form-that-uses-a-background-operation.md @@ -19,6 +19,7 @@ helpviewer_keywords: ms.assetid: 9f483f93-1613-4be1-a021-b4934e9c78f3 --- # How to: Implement a Form That Uses a Background Operation + The following example program creates a form that calculates Fibonacci numbers. The calculation runs on a thread that is separate from the user interface thread, so the user interface continues to run without delays as the calculation proceeds. There is extensive support for this task in Visual Studio. @@ -26,11 +27,13 @@ The following example program creates a form that calculates Fibonacci numbers. Also see [Walkthrough: Implementing a Form That Uses a Background Operation](walkthrough-implementing-a-form-that-uses-a-background-operation.md). ## Example + [!code-cpp[System.ComponentModel.BackgroundWorker#1](~/samples/snippets/cpp/VS_Snippets_Winforms/System.ComponentModel.BackgroundWorker/CPP/fibonacciform.cpp#1)] [!code-csharp[System.ComponentModel.BackgroundWorker#1](~/samples/snippets/csharp/VS_Snippets_Winforms/System.ComponentModel.BackgroundWorker/CS/fibonacciform.cs#1)] [!code-vb[System.ComponentModel.BackgroundWorker#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.ComponentModel.BackgroundWorker/VB/fibonacciform.vb#1)] ## Compiling the Code + This example requires: - References to the System, System.Drawing, and System.Windows.Forms assemblies. @@ -38,11 +41,11 @@ The following example program creates a form that calculates Fibonacci numbers. ## Robust Programming > [!CAUTION] -> When using multithreading of any sort, you potentially expose yourself to very serious and complex bugs. Consult the [Managed Threading Best Practices](https://docs.microsoft.com/dotnet/standard/threading/managed-threading-best-practices) before implementing any solution that uses multithreading. +> When using multithreading of any sort, you potentially expose yourself to very serious and complex bugs. Consult the [Managed Threading Best Practices](/dotnet/standard/threading/managed-threading-best-practices) before implementing any solution that uses multithreading. ## See also - - -- [Event-based Asynchronous Pattern Overview](https://docs.microsoft.com/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) -- [Managed Threading Best Practices](https://docs.microsoft.com/dotnet/standard/threading/managed-threading-best-practices) +- [Event-based Asynchronous Pattern Overview](/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) +- [Managed Threading Best Practices](/dotnet/standard/threading/managed-threading-best-practices) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-existing-windows-forms-controls.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-existing-windows-forms-controls.md index 36d41024bd..bca56e5256 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-existing-windows-forms-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-existing-windows-forms-controls.md @@ -85,5 +85,5 @@ If you want to extend the functionality of an existing control, you can create a - [How to: Inherit from the Control Class](how-to-inherit-from-the-control-class.md) - [How to: Inherit from the UserControl Class](how-to-inherit-from-the-usercontrol-class.md) - [How to: Author Controls for Windows Forms](how-to-author-controls-for-windows-forms.md) -- [Troubleshooting Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) +- [Troubleshooting Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) - [Walkthrough: Inheriting from a Windows Forms Control](walkthrough-inheriting-from-a-windows-forms-control-with-visual-csharp.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-the-control-class.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-the-control-class.md index 2cfcde796f..6d30303351 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-the-control-class.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-the-control-class.md @@ -44,5 +44,5 @@ If you want to create a completely custom control to use on a Windows Form, you - [How to: Inherit from the UserControl Class](how-to-inherit-from-the-usercontrol-class.md) - [How to: Inherit from Existing Windows Forms Controls](how-to-inherit-from-existing-windows-forms-controls.md) - [How to: Author Controls for Windows Forms](how-to-author-controls-for-windows-forms.md) -- [Troubleshooting Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) +- [Troubleshooting Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) - [Developing Windows Forms Controls at Design Time](developing-windows-forms-controls-at-design-time.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-the-usercontrol-class.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-the-usercontrol-class.md index ed77e3154d..50b3c4fd05 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-the-usercontrol-class.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-inherit-from-the-usercontrol-class.md @@ -35,5 +35,5 @@ To combine the functionality of one or more Windows Forms controls with custom c - [How to: Inherit from the Control Class](how-to-inherit-from-the-control-class.md) - [How to: Inherit from Existing Windows Forms Controls](how-to-inherit-from-existing-windows-forms-controls.md) - [How to: Author Controls for Windows Forms](how-to-author-controls-for-windows-forms.md) -- [Troubleshoot Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) +- [Troubleshoot Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) - [How to: Test the Run-Time Behavior of a UserControl](how-to-test-the-run-time-behavior-of-a-usercontrol.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-iterate-through-all-nodes-of-a-windows-forms-treeview-control.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-iterate-through-all-nodes-of-a-windows-forms-treeview-control.md index a9dafbae3e..d561fd1ea6 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-iterate-through-all-nodes-of-a-windows-forms-treeview-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-iterate-through-all-nodes-of-a-windows-forms-treeview-control.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: 427f8928-ebcf-4beb-887f-695b905d5134 --- # How to: Iterate Through All Nodes of a Windows Forms TreeView Control + It is sometimes useful to examine every node in a Windows Forms control in order to perform some calculation on the node values. This operation can be done using a recursive procedure (recursive method in C# and C++) that iterates through each node in each collection of the tree. Each object in a tree view has properties that you can use to navigate the tree view: , , , , and . The value of the property is the parent node of the current node. The child nodes of the current node, if there are any, are listed in its property. The control itself has the property, which is the root node of the entire tree view. @@ -120,4 +121,4 @@ It is sometimes useful to examine every node in a Windows Forms control can display a ``` > [!IMPORTANT] - > To run this process, your assembly may require a privilege level granted by the class. If you are running in a partial-trust context, the process might throw an exception because of insufficient privileges. For more information, see [Code Access Security Basics](https://docs.microsoft.com/dotnet/framework/misc/code-access-security-basics). + > To run this process, your assembly may require a privilege level granted by the class. If you are running in a partial-trust context, the process might throw an exception because of insufficient privileges. For more information, see [Code Access Security Basics](/dotnet/framework/misc/code-access-security-basics). ## See also diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls.md index a978135bc3..89ecc62820 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls.md @@ -19,7 +19,7 @@ ms.assetid: 138f38b6-1099-4fd5-910c-390b41cbad35 --- # How to: Make thread-safe calls to Windows Forms controls -Multithreading can improve the performance of Windows Forms apps, but access to Windows Forms controls isn't inherently thread-safe. Multithreading can expose your code to very serious and complex bugs. Two or more threads manipulating a control can force the control into an inconsistent state and lead to race conditions, deadlocks, and freezes or hangs. If you implement multithreading in your app, be sure to call cross-thread controls in a thread-safe way. For more information, see [Managed threading best practices](https://docs.microsoft.com/dotnet/standard/threading/managed-threading-best-practices). +Multithreading can improve the performance of Windows Forms apps, but access to Windows Forms controls isn't inherently thread-safe. Multithreading can expose your code to very serious and complex bugs. Two or more threads manipulating a control can force the control into an inconsistent state and lead to race conditions, deadlocks, and freezes or hangs. If you implement multithreading in your app, be sure to call cross-thread controls in a thread-safe way. For more information, see [Managed threading best practices](/dotnet/standard/threading/managed-threading-best-practices). There are two ways to safely call a Windows Forms control from a thread that didn't create that control. You can use the method to call a delegate created in the main thread, which in turn calls the control. Or, you can implement a , which uses an event-driven model to separate work done in the background thread from reporting on the results. @@ -61,7 +61,7 @@ The following code examples demonstrate two ways to safely call a Windows Forms In both examples, the background thread sleeps for one second to simulate work being done in that thread. -You can build and run these examples as .NET Framework apps from the C# or Visual Basic command line. For more information, see [Command-line building with csc.exe](https://docs.microsoft.com/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe) or [Build from the command line (Visual Basic)](https://docs.microsoft.com/dotnet/visual-basic/reference/command-line-compiler/building-from-the-command-line). +You can build and run these examples as .NET Framework apps from the C# or Visual Basic command line. For more information, see [Command-line building with csc.exe](/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe) or [Build from the command line (Visual Basic)](/dotnet/visual-basic/reference/command-line-compiler/building-from-the-command-line). Starting with .NET Core 3.0, you can also build and run the examples as Windows .NET Core apps from a folder that has a .NET Core Windows Forms *\.csproj* project file. diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-open-files-using-the-openfiledialog-component.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-open-files-using-the-openfiledialog-component.md index 6659dea9a6..e46d5d54d7 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-open-files-using-the-openfiledialog-component.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-open-files-using-the-openfiledialog-component.md @@ -15,9 +15,9 @@ ms.assetid: 9d88367a-cc21-4ffd-be74-89fd63767d35 The component opens the Windows dialog box for browsing and selecting files. To open and read the selected files, you can use the method, or create an instance of the class. The following examples show both approaches. -In .NET Framework, to get or set the property requires a privilege level granted by the class. The examples run a permission check, and can throw an exception due to insufficient privileges if run in a partial-trust context. For more information, see [Code access security basics](https://docs.microsoft.com/dotnet/framework/misc/code-access-security-basics). +In .NET Framework, to get or set the property requires a privilege level granted by the class. The examples run a permission check, and can throw an exception due to insufficient privileges if run in a partial-trust context. For more information, see [Code access security basics](/dotnet/framework/misc/code-access-security-basics). -You can build and run these examples as .NET Framework apps from the C# or Visual Basic command line. For more information, see [Command-line building with csc.exe](https://docs.microsoft.com/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe) or [Build from the command line](https://docs.microsoft.com/dotnet/visual-basic/reference/command-line-compiler/building-from-the-command-line). +You can build and run these examples as .NET Framework apps from the C# or Visual Basic command line. For more information, see [Command-line building with csc.exe](/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe) or [Build from the command line](/dotnet/visual-basic/reference/command-line-compiler/building-from-the-command-line). Starting with .NET Core 3.0, you can also build and run the examples as Windows .NET Core apps from a folder that has a .NET Core Windows Forms *\.csproj* project file. diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-position-controls-on-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-position-controls-on-windows-forms.md index a24853374e..3d820e377b 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-position-controls-on-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-position-controls-on-windows-forms.md @@ -100,4 +100,4 @@ button1->Left += 200; - [Labeling Individual Windows Forms Controls and Providing Shortcuts to Them](labeling-individual-windows-forms-controls-and-providing-shortcuts-to-them.md) - [Controls to Use on Windows Forms](controls-to-use-on-windows-forms.md) - [Windows Forms Controls by Function](windows-forms-controls-by-function.md) -- [How to: Set the Screen Location of Windows Forms](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/52aha046(v=vs.100)) +- [How to: Set the Screen Location of Windows Forms](/previous-versions/visualstudio/visual-studio-2010/52aha046(v=vs.100)) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-provide-a-toolbox-bitmap-for-a-control.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-provide-a-toolbox-bitmap-for-a-control.md index 6bb945b246..badd2883ed 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-provide-a-toolbox-bitmap-for-a-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-provide-a-toolbox-bitmap-for-a-control.md @@ -15,7 +15,7 @@ manager: jillfra --- # How to: Provide a Toolbox Bitmap for a Control -If you want to have a special icon for your control appear in the **Toolbox** of Visual Studio, you can specify a particular image by using the . This class is an *attribute*, a special kind of class you can attach to other classes. For more information about attributes, see [Attributes overview (Visual Basic)](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/concepts/attributes/index) for Visual Basic or [Attributes (C#)](https://docs.microsoft.com/dotnet/csharp/programming-guide/concepts/attributes/index) for C#. +If you want to have a special icon for your control appear in the **Toolbox** of Visual Studio, you can specify a particular image by using the . This class is an *attribute*, a special kind of class you can attach to other classes. For more information about attributes, see [Attributes overview (Visual Basic)](/dotnet/visual-basic/programming-guide/concepts/attributes/index) for Visual Basic or [Attributes (C#)](/dotnet/csharp/programming-guide/concepts/attributes/index) for C#. Using the , you can specify a string that indicates the path and file name for a 16 by 16 pixel bitmap. This bitmap then appears next to your control when added to the **Toolbox**. You can also specify a , in which case the bitmap associated with that type is loaded. If you specify both a and a string, the control searches for an image resource with the name specified by the string parameter in the assembly containing the type specified by the parameter. @@ -66,5 +66,5 @@ Using the , you can specify a string - - [Walkthrough: Automatically Populating the Toolbox with Custom Components](walkthrough-automatically-populating-the-toolbox-with-custom-components.md) - [Developing Windows Forms Controls at Design Time](developing-windows-forms-controls-at-design-time.md) -- [Attributes overview (Visual Basic)](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/concepts/attributes/index) -- [Attributes (C#)](https://docs.microsoft.com/dotnet/csharp/programming-guide/concepts/attributes/index) +- [Attributes overview (Visual Basic)](/dotnet/visual-basic/programming-guide/concepts/attributes/index) +- [Attributes (C#)](/dotnet/csharp/programming-guide/concepts/attributes/index) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-resize-controls-on-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-resize-controls-on-windows-forms.md index 0ad6e03de9..d0298c07bb 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-resize-controls-on-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-resize-controls-on-windows-forms.md @@ -36,4 +36,4 @@ In Visual Studio, select the control to be resized and drag one of the eight siz - [Labeling Individual Windows Forms Controls and Providing Shortcuts to Them](labeling-individual-windows-forms-controls-and-providing-shortcuts-to-them.md) - [Controls to Use on Windows Forms](controls-to-use-on-windows-forms.md) - [Windows Forms Controls by Function](windows-forms-controls-by-function.md) -- [How to: Resize Windows Forms Using the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/37k2zkwx(v=vs.100)) +- [How to: Resize Windows Forms Using the Designer](/previous-versions/visualstudio/visual-studio-2010/37k2zkwx(v=vs.100)) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-save-files-using-the-savefiledialog-component.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-save-files-using-the-savefiledialog-component.md index ce3fe8fdd5..18aa636346 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-save-files-using-the-savefiledialog-component.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-save-files-using-the-savefiledialog-component.md @@ -28,7 +28,7 @@ The component allows users to browse In the example below, there is a control with an image assigned to it. When you click the button, a component is instantiated with a filter that allows files of type .gif, .jpeg, and .bmp. If a file of this type is selected in the Save File dialog box, the button's image is saved. > [!IMPORTANT] - > To get or set the property, your assembly requires a privilege level granted by the class. If you are running in a partial-trust context, the process might throw an exception due to insufficient privileges. For more information, see [Code Access Security Basics](https://docs.microsoft.com/dotnet/framework/misc/code-access-security-basics). + > To get or set the property, your assembly requires a privilege level granted by the class. If you are running in a partial-trust context, the process might throw an exception due to insufficient privileges. For more information, see [Code Access Security Basics](/dotnet/framework/misc/code-access-security-basics). The example assumes your form has a control with its property set to a file of type .gif, .jpeg, or .bmp. diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-set-pictures-at-run-time-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-set-pictures-at-run-time-windows-forms.md index 02f050a9ca..413cc51868 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-set-pictures-at-run-time-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-set-pictures-at-run-time-windows-forms.md @@ -15,6 +15,7 @@ helpviewer_keywords: ms.assetid: 18ca41d0-68a5-4660-985e-a6c1fbc01d76 --- # How to: Set Pictures at Run Time (Windows Forms) + You can programmatically set the image displayed by a Windows Forms control. ### To set a picture programmatically @@ -87,7 +88,7 @@ You can programmatically set the image displayed by a Windows Forms [!NOTE] - > For more information on why you should use the method in this way, see [Cleaning Up Unmanaged Resources](https://docs.microsoft.com/dotnet/standard/garbage-collection/unmanage). + > For more information on why you should use the method in this way, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanage). This code will clear the image even if a graphic was loaded into the control at design time. diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-test-the-run-time-behavior-of-a-usercontrol.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-test-the-run-time-behavior-of-a-usercontrol.md index ca6172db60..5893ff1e0b 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-test-the-run-time-behavior-of-a-usercontrol.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-test-the-run-time-behavior-of-a-usercontrol.md @@ -18,7 +18,6 @@ When you develop a , you need to test its > [!IMPORTANT] > For the test container to load your , the control must have at least one public constructor. - > [!NOTE] > A Visual C++ control cannot be tested using the **UserControl Test Container**. @@ -65,4 +64,4 @@ You can test user controls from other projects in your current project's test co - - [How to: Author Composite Controls](how-to-author-composite-controls.md) - [Walkthrough: Authoring a Composite Control](walkthrough-authoring-a-composite-control-with-visual-csharp.md) -- [User Control Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/183c3hth(v=vs.100)) +- [User Control Designer](/previous-versions/visualstudio/visual-studio-2010/183c3hth(v=vs.100)) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-use-a-background-thread-to-search-for-files.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-use-a-background-thread-to-search-for-files.md index 0dcaa8b970..17a23627e9 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-use-a-background-thread-to-search-for-files.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-use-a-background-thread-to-search-for-files.md @@ -12,9 +12,10 @@ helpviewer_keywords: ms.assetid: 7fe3956f-5b8f-4f78-8aae-c9eb0b28f13a --- # How to: Use a Background Thread to Search for Files + The component replaces and adds functionality to the namespace; however, the namespace is retained for both backward compatibility and future use, if you choose. For more information, see [BackgroundWorker Component Overview](backgroundworker-component-overview.md). - Windows Forms uses the single-threaded apartment (STA) model because Windows Forms is based on native Win32 windows that are inherently apartment-threaded. The STA model implies that a window can be created on any thread, but it cannot switch threads once created, and all function calls to it must occur on its creation thread. Outside Windows Forms, classes in the .NET Framework use the free threading model. For information about threading in the .NET Framework, see [Threading](https://docs.microsoft.com/dotnet/standard/threading/index). + Windows Forms uses the single-threaded apartment (STA) model because Windows Forms is based on native Win32 windows that are inherently apartment-threaded. The STA model implies that a window can be created on any thread, but it cannot switch threads once created, and all function calls to it must occur on its creation thread. Outside Windows Forms, classes in the .NET Framework use the free threading model. For information about threading in the .NET Framework, see [Threading](/dotnet/standard/threading/index). The STA model requires that any methods on a control that need to be called from outside the control's creation thread must be marshaled to (executed on) the control's creation thread. The base class provides several methods (, , and ) for this purpose. makes synchronous method calls; makes asynchronous method calls. @@ -563,6 +564,7 @@ namespace Microsoft.Samples.DirectorySearcher ``` ## Using the Multithreaded Control on a Form + The following example shows how the multithreaded `DirectorySearcher` control can be used on a form. ```vb @@ -758,4 +760,4 @@ namespace SampleUsage - - [Developing Custom Windows Forms Controls with the .NET Framework](developing-custom-windows-forms-controls.md) -- [Event-based Asynchronous Pattern Overview](https://docs.microsoft.com/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) +- [Event-based Asynchronous Pattern Overview](/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-validate-data-in-the-windows-forms-datagridview-control.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-validate-data-in-the-windows-forms-datagridview-control.md index 85da98b1cf..41c89a715b 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-validate-data-in-the-windows-forms-datagridview-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-validate-data-in-the-windows-forms-datagridview-control.md @@ -12,21 +12,25 @@ helpviewer_keywords: ms.assetid: d10aef35-701e-4a3c-a684-2a2ed1aeaca6 --- # How to: Validate Data in the Windows Forms DataGridView Control + The following code example demonstrates how to validate data entered by a user into a control. In this example, the is populated with rows from the `Customers` table of the Northwind sample database. When the user edits a cell in the `CompanyName` column, its value is tested for validity by checking that it is not empty. If the event handler for the event finds that the value is an empty string, the prevents the user from exiting the cell until a non-empty string is entered. For a complete explanation of this code example, see [Walkthrough: Validating Data in the Windows Forms DataGridView Control](walkthrough-validating-data-in-the-windows-forms-datagridview-control.md). ## Example + [!code-csharp[System.Windows.Forms.DataGridViewDataValidation#00](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewDataValidation/CS/datavalidation.cs#00)] [!code-vb[System.Windows.Forms.DataGridViewDataValidation#00](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewDataValidation/VB/datavalidation.vb#00)] ## Compiling the Code + This example requires: - References to the System, System.Data, System.Windows.Forms and System.XML assemblies. ## .NET Framework Security - Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information). + + Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information). ## See also @@ -35,4 +39,4 @@ The following code example demonstrates how to validate data entered by a user i - [Walkthrough: Validating Data in the Windows Forms DataGridView Control](walkthrough-validating-data-in-the-windows-forms-datagridview-control.md) - [Data Entry in the Windows Forms DataGridView Control](data-entry-in-the-windows-forms-datagridview-control.md) - [Walkthrough: Handling Errors that Occur During Data Entry in the Windows Forms DataGridView Control](handling-errors-that-occur-during-data-entry-in-the-datagrid.md) -- [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information) +- [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information) diff --git a/dotnet-desktop-guide/framework/winforms/controls/implementing-virtual-mode-jit-data-loading-in-the-datagrid.md b/dotnet-desktop-guide/framework/winforms/controls/implementing-virtual-mode-jit-data-loading-in-the-datagrid.md index 4fb5ad3366..8c6f130456 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/implementing-virtual-mode-jit-data-loading-in-the-datagrid.md +++ b/dotnet-desktop-guide/framework/winforms/controls/implementing-virtual-mode-jit-data-loading-in-the-datagrid.md @@ -14,6 +14,7 @@ helpviewer_keywords: ms.assetid: c2a052b9-423c-4ff7-91dc-d8c7c79345f6 --- # Implementing Virtual Mode with Just-In-Time Data Loading in the Windows Forms DataGridView Control + One reason to implement virtual mode in the control is to retrieve data only as it is needed. This is called *just-in-time data loading*. If you are working with a very large table in a remote database, for example, you might want to avoid startup delays by retrieving only the data that is necessary for display and retrieving additional data only when the user scrolls new rows into view. If the client computers running your application have a limited amount of memory available for storing data, you might also want to discard unused data when retrieving new values from the database. @@ -23,17 +24,19 @@ One reason to implement virtual mode in the control that interacts with a `Cache` object through a event handler. The `Cache` object manages the locally stored values and uses a `DataRetriever` object to retrieve values from the Orders table of the sample Northwind database. The `DataRetriever` object, which implements the `IDataPageRetriever` interface required by the `Cache` class, is also used to initialize the control rows and columns. The `IDataPageRetriever`, `DataRetriever`, and `Cache` types are described later in this topic. > [!NOTE] -> Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information). +> Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information). [!code-csharp[System.Windows.Forms.DataGridView.Virtual_lazyloading#100](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.Virtual_lazyloading/CS/lazyloading.cs#100)] [!code-vb[System.Windows.Forms.DataGridView.Virtual_lazyloading#100](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.Virtual_lazyloading/VB/lazyloading.vb#100)] ## The IDataPageRetriever Interface + The following code example defines the `IDataPageRetriever` interface, which is implemented by the `DataRetriever` class. The only method declared in this interface is the `SupplyPageOfData` method, which requires an initial row index and a count of the number of rows in a single page of data. These values are used by the implementer to retrieve a subset of data from a data source. A `Cache` object uses an implementation of this interface during construction to load two initial pages of data. Whenever an uncached value is needed, the cache discards one of these pages and requests a new page containing the value from the `IDataPageRetriever`. @@ -42,12 +45,14 @@ One reason to implement virtual mode in the control uses to create the necessary columns and to add the appropriate number of empty rows to the collection. Adding the empty rows is necessary so that the control will behave as though it contains all the data in the table. This means that the scroll box in the scroll bar will have the appropriate size, and the user will be able to access any row in the table. The rows are filled by the event handler only when they are scrolled into view. [!code-csharp[System.Windows.Forms.DataGridView.Virtual_lazyloading#200](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.Virtual_lazyloading/CS/lazyloading.cs#200)] [!code-vb[System.Windows.Forms.DataGridView.Virtual_lazyloading#200](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.Virtual_lazyloading/VB/lazyloading.vb#200)] ## The Cache Class + The following code example defines the `Cache` class, which manages two pages of data populated through an `IDataPageRetriever` implementation. The `Cache` class defines an inner `DataPage` structure, which contains a to store the values in a single cache page and which calculates the row indexes that represent the upper and lower boundaries of the page. The `Cache` class loads two pages of data at construction time. Whenever the event requests a value, the `Cache` object determines if the value is available in one of its two pages and, if so, returns it. If the value is not available locally, the `Cache` object determines which of its two pages is farthest from the currently displayed rows and replaces the page with a new one containing the requested value, which it then returns. @@ -58,6 +63,7 @@ One reason to implement virtual mode in the control. For best results, you will need to conduct performance testing and usability testing to determine the requirements of your system and your users. Several factors that you will need to take into consideration include the amount of memory in the client machines running your application, the available bandwidth of the network connection used, and the latency of the server used. The bandwidth and latency should be determined at times of peak usage. diff --git a/dotnet-desktop-guide/framework/winforms/controls/index.md b/dotnet-desktop-guide/framework/winforms/controls/index.md index b733cbd7a7..a7bf290ca9 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/index.md +++ b/dotnet-desktop-guide/framework/winforms/controls/index.md @@ -34,5 +34,5 @@ Describes techniques for creating custom controls through design and inheritance ## Related sections -[Client Applications](https://docs.microsoft.com/dotnet/framework/develop-client-apps)\ +[Client Applications](/dotnet/framework/develop-client-apps)\ Provides an overview of developing Windows-based applications. diff --git a/dotnet-desktop-guide/framework/winforms/controls/limitations-of-the-timer-component-interval-property.md b/dotnet-desktop-guide/framework/winforms/controls/limitations-of-the-timer-component-interval-property.md index 520e2ae069..cba4994da3 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/limitations-of-the-timer-component-interval-property.md +++ b/dotnet-desktop-guide/framework/winforms/controls/limitations-of-the-timer-component-interval-property.md @@ -9,11 +9,13 @@ helpviewer_keywords: ms.assetid: 7e5fb513-77e7-4046-a8e8-aab94e61ca0f --- # Limitations of the Windows Forms Timer Component's Interval Property + The Windows Forms component has an property that specifies the number of milliseconds that pass between one timer event and the next. Unless the component is disabled, a timer continues to receive the event at roughly equal intervals of time. - This component is designed for a Windows Forms environment. If you need a timer that is suitable for a server environment, see [Introduction to Server-Based Timers](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)). + This component is designed for a Windows Forms environment. If you need a timer that is suitable for a server environment, see [Introduction to Server-Based Timers](/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)). ## The Interval Property + The property has a few limitations to consider when you are programming a component: - If your application or another application is making heavy demands on the system — such as long loops, intensive calculations, or drive, network, or port access — your application may not get timer events as often as the property specifies. diff --git a/dotnet-desktop-guide/framework/winforms/controls/menustrip-control-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/menustrip-control-windows-forms.md index 16a9d55137..6a9359bd37 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/menustrip-control-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/menustrip-control-windows-forms.md @@ -7,9 +7,11 @@ helpviewer_keywords: ms.assetid: e361bf98-eed8-4ed3-9dfb-5a2e865e3ce6 --- # MenuStrip Control (Windows Forms) + This control groups application commands and makes them easily accessible. ## In This Section + [MenuStrip Control Overview](menustrip-control-overview-windows-forms.md) Explains what the control is and its key features and properties. @@ -49,7 +51,7 @@ This control groups application commands and makes them easily accessible. [How to: Set Up Automatic Menu Merging for MDI Applications](how-to-set-up-automatic-menu-merging-for-mdi-applications.md) Describes how to merge menu items automatically at run time. -- [MenuStrip Items Collection Editor](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233625(v=vs.100)) +- [MenuStrip Items Collection Editor](/previous-versions/visualstudio/visual-studio-2010/ms233625(v=vs.100)) - [How to: Copy ToolStripMenuItems](how-to-copy-toolstripmenuitems.md) @@ -61,9 +63,10 @@ This control groups application commands and makes them easily accessible. - [Walkthrough: Providing Standard Menu Items to a Form](walkthrough-providing-standard-menu-items-to-a-form.md) -- [MenuStrip Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233645(v=vs.100)) +- [MenuStrip Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233645(v=vs.100)) ## Reference + Describes the features of the class, which provides a menu system for a form. @@ -74,5 +77,6 @@ This control groups application commands and makes them easily accessible. Describes the features of the class, which represents a selectable option displayed on a or . ## Related Sections + [Controls to Use on Windows Forms](controls-to-use-on-windows-forms.md) Provides a complete list of Windows Forms controls, with links to information on their use. diff --git a/dotnet-desktop-guide/framework/winforms/controls/method-implementation-in-custom-controls.md b/dotnet-desktop-guide/framework/winforms/controls/method-implementation-in-custom-controls.md index 388ed241bb..21973acd95 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/method-implementation-in-custom-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/method-implementation-in-custom-controls.md @@ -13,6 +13,7 @@ helpviewer_keywords: ms.assetid: 35d14fca-4bb4-4a27-8211-1f7a98ea27de --- # Method Implementation in Custom Controls + A method is implemented in a control in the same manner a method would be implemented in any other component. In Visual Basic, if a method is required to return a value, it is implemented as a `Public Function`. If no value is returned, it is implemented as a `Public Sub`. Methods are declared using the following syntax: @@ -39,6 +40,7 @@ public int ConvertMatterToEnergy(int matter) Typed arguments allow many developer errors to be caught by the compiler, rather than at run time. The compiler always catches errors, whereas run-time testing is only as good as the test suite. ## Overloaded Methods + If you want to allow users of your control to supply different combinations of parameters to a method, provide multiple overloads of the method, using explicit data types. Avoid creating parameters declared `As Object` that can contain any data type, as this can lead to errors that might not be caught in testing. > [!NOTE] @@ -71,5 +73,5 @@ public void Spin(Widget driver) ## See also -- [Events](https://docs.microsoft.com/dotnet/standard/events/index) +- [Events](/dotnet/standard/events/index) - [Properties in Windows Forms Controls](properties-in-windows-forms-controls.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/move-through-a-dataset-with-wf-bindingnavigator-control.md b/dotnet-desktop-guide/framework/winforms/controls/move-through-a-dataset-with-wf-bindingnavigator-control.md index cc8a0032fe..82198fc1a8 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/move-through-a-dataset-with-wf-bindingnavigator-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/move-through-a-dataset-with-wf-bindingnavigator-control.md @@ -11,18 +11,21 @@ helpviewer_keywords: ms.assetid: 146d97be-3d97-400e-accb-860bbf47729d --- # How to: Move Through a DataSet with the Windows Forms BindingNavigator Control + As you build data-driven applications, you will often need to display collections of data to users. The control, in conjunction with the component, provides a convenient and extensible solution for moving through a collection and displaying items sequentially. ## Example + The following code example demonstrates how to use a control to move through data. The set is contained in a , which is bound to a control with a component. > [!NOTE] -> Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information). +> Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information). [!code-csharp[System.Windows.Forms.DataNavigator#1](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataNavigator/CS/form1.cs#1)] [!code-vb[System.Windows.Forms.DataNavigator#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataNavigator/VB/form1.vb#1)] ## Compiling the Code + This example requires: - References to the System, System.Data, System.Drawing, System.Windows.Forms and System.Xml assemblies. diff --git a/dotnet-desktop-guide/framework/winforms/controls/overriding-the-onpaint-method.md b/dotnet-desktop-guide/framework/winforms/controls/overriding-the-onpaint-method.md index 15792c60c1..09ee021c25 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/overriding-the-onpaint-method.md +++ b/dotnet-desktop-guide/framework/winforms/controls/overriding-the-onpaint-method.md @@ -10,6 +10,7 @@ helpviewer_keywords: ms.assetid: e9ca2723-0107-4540-bb21-4f5ffb4a9906 --- # Overriding the OnPaint Method + The basic steps for overriding any event defined in the .NET Framework are identical and are summarized in the following list. #### To override an inherited event @@ -82,6 +83,6 @@ public class PaintEventArgs : EventArgs { ## See also -- [Events](https://docs.microsoft.com/dotnet/standard/events/index) +- [Events](/dotnet/standard/events/index) - [Rendering a Windows Forms Control](rendering-a-windows-forms-control.md) - [Defining an Event](defining-an-event-in-windows-forms-controls.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/printdocument-component-overview-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/printdocument-component-overview-windows-forms.md index 4ae01c2bcb..8f0a0b0aff 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/printdocument-component-overview-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/printdocument-component-overview-windows-forms.md @@ -18,7 +18,7 @@ Two of the main scenarios that involve the component to a Windows Form, then add programming logic that prints a file in the event handler. The programming logic should culminate with the method to print the document. This method sends a object, contained in the property of the class, to the printer. For an example that shows how to print a text document using the component, see [How to: Print a Multi-Page Text File in Windows Forms](../advanced/how-to-print-a-multi-page-text-file-in-windows-forms.md). -- More complex print jobs, such as a situation where you will want to reuse printing logic you have written. In such a case you would derive a new component from the component and override (see [Overrides](https://docs.microsoft.com/dotnet/visual-basic/language-reference/modifiers/overrides) for Visual Basic or [override](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/override) for C#) the event. +- More complex print jobs, such as a situation where you will want to reuse printing logic you have written. In such a case you would derive a new component from the component and override (see [Overrides](/dotnet/visual-basic/language-reference/modifiers/overrides) for Visual Basic or [override](/dotnet/csharp/language-reference/keywords/override) for C#) the event. When it is added to a form, the component appears in the tray at the bottom of the Windows Forms Designer in Visual Studio. diff --git a/dotnet-desktop-guide/framework/winforms/controls/printpreviewdialog-control-overview-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/printpreviewdialog-control-overview-windows-forms.md index 527f6e05a2..89e91c0a65 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/printpreviewdialog-control-overview-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/printpreviewdialog-control-overview-windows-forms.md @@ -34,7 +34,7 @@ For apps running on the .NET Framework 4.5.2, you can add the following key to t If the `EnablePrintPreviewOptimization` key is set to any other value, or if the key is not present, the optimization is not applied. -For apps running on the .NET Framework 4.6 or later versions, you can add the following switch to the [\](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/runtime/appcontextswitchoverrides-element) element in the [\](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/runtime/index) section of your app config file: +For apps running on the .NET Framework 4.6 or later versions, you can add the following switch to the [\](/dotnet/framework/configure-apps/file-schema/runtime/appcontextswitchoverrides-element) element in the [\](/dotnet/framework/configure-apps/file-schema/runtime/index) section of your app config file: ```xml diff --git a/dotnet-desktop-guide/framework/winforms/controls/properties-in-windows-forms-controls.md b/dotnet-desktop-guide/framework/winforms/controls/properties-in-windows-forms-controls.md index 295a100252..21a000679a 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/properties-in-windows-forms-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/properties-in-windows-forms-controls.md @@ -8,11 +8,13 @@ helpviewer_keywords: ms.assetid: 2785279b-fb57-4937-8f6b-2050e475db6f --- # Properties in Windows Forms Controls + A Windows Forms control inherits many properties form the base class . These include properties such as , , , , , , , , , , , , and many others. For details about inherited properties, see . You can override inherited properties in your control as well as define new properties. ## In This Section + [Defining a Property](defining-a-property-in-windows-forms-controls.md) Shows how to implement a property for a custom control or component and shows how to integrate the property into the design environment. @@ -29,6 +31,7 @@ A Windows Forms control inherits many properties form the base class Documents the base class for implementing composite controls. @@ -39,11 +42,12 @@ A Windows Forms control inherits many properties form the base class to use for a custom property. ## Related Sections + [Attributes in Windows Forms Controls](attributes-in-windows-forms-controls.md) Describes the attributes you can apply to properties or other members of your custom controls and components. - [Design-Time Attributes for Components](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/tk67c2t8(v=vs.120)) + [Design-Time Attributes for Components](/previous-versions/visualstudio/visual-studio-2013/tk67c2t8(v=vs.120)) Lists metadata attributes to apply to components and controls so that they are displayed correctly at design time in visual designers. - [Extending Design-Time Support](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) + [Extending Design-Time Support](/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) Describes how to implement classes such as editors and designers that provide design-time support. diff --git a/dotnet-desktop-guide/framework/winforms/controls/property-changed-events.md b/dotnet-desktop-guide/framework/winforms/controls/property-changed-events.md index b3ea87b2ba..67e362caeb 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/property-changed-events.md +++ b/dotnet-desktop-guide/framework/winforms/controls/property-changed-events.md @@ -10,7 +10,8 @@ helpviewer_keywords: ms.assetid: 268039ec-5aaa-4d76-b902-acccb036c850 --- # Property-Changed Events -If you want your control to send notifications when a property named *PropertyName* changes, define an event named *PropertyName*`Changed` and a method named `On`*PropertyName*`Changed` that raises the event. The naming convention in Windows Forms is to append the word *Changed* to the name of the property. The associated event delegate type for property-changed events is , and the event data type is . The base class defines many property-changed events, such as , , , , and others. For background information about events, see [Events](https://docs.microsoft.com/dotnet/standard/events/index) and [Events in Windows Forms Controls](events-in-windows-forms-controls.md). + +If you want your control to send notifications when a property named *PropertyName* changes, define an event named *PropertyName*`Changed` and a method named `On`*PropertyName*`Changed` that raises the event. The naming convention in Windows Forms is to append the word *Changed* to the name of the property. The associated event delegate type for property-changed events is , and the event data type is . The base class defines many property-changed events, such as , , , , and others. For background information about events, see [Events](/dotnet/standard/events/index) and [Events in Windows Forms Controls](events-in-windows-forms-controls.md). Property-changed events are useful because they allow consumers of a control to attach event handlers that respond to the change. If your control needs to respond to a property-changed event that it raises, override the corresponding `On`*PropertyName*`Changed` method instead of attaching a delegate to the event. A control typically responds to a property-changed event by updating other properties or by redrawing some or all of its drawing surface. @@ -21,6 +22,6 @@ If you want your control to send notifications when a property named *PropertyNa ## See also -- [Events](https://docs.microsoft.com/dotnet/standard/events/index) +- [Events](/dotnet/standard/events/index) - [Events in Windows Forms Controls](events-in-windows-forms-controls.md) - [Properties in Windows Forms Controls](properties-in-windows-forms-controls.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/raise-change-notifications--bindingsource.md b/dotnet-desktop-guide/framework/winforms/controls/raise-change-notifications--bindingsource.md index b66aa82720..e4d56aab8f 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/raise-change-notifications--bindingsource.md +++ b/dotnet-desktop-guide/framework/winforms/controls/raise-change-notifications--bindingsource.md @@ -15,20 +15,23 @@ helpviewer_keywords: ms.assetid: 7fa2cf51-c09f-4375-adf0-e36c5617f099 --- # How to: Raise Change Notifications Using a BindingSource and the INotifyPropertyChanged Interface + The component automatically detects changes in a data source when the type contained in the data source implements and raises events when a property value is changed. This change detection is useful because controls bound to the automatically update as the data source values change. > [!NOTE] > If your data source implements and you are performing asynchronous operations, you should not make changes to the data source on a background thread. Instead, you should read the data on a background thread and merge the data into a list on the UI thread. ## Example + The following code example demonstrates a simple implementation of the interface. It also shows how the automatically passes a data source change to a bound control when the is bound to a list of the type. - If you use the `CallerMemberName` attribute, calls to the `NotifyPropertyChanged` method don't have to specify the property name as a string argument. For more information, see [Caller Information (C#)](https://docs.microsoft.com/dotnet/csharp/language-reference/attributes/caller-information) or [Caller Information (Visual Basic)](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/concepts/caller-information). + If you use the `CallerMemberName` attribute, calls to the `NotifyPropertyChanged` method don't have to specify the property name as a string argument. For more information, see [Caller Information (C#)](/dotnet/csharp/language-reference/attributes/caller-information) or [Caller Information (Visual Basic)](/dotnet/visual-basic/programming-guide/concepts/caller-information). [!code-csharp[System.ComponentModel.IPropertyChangeExample#1](~/samples/snippets/csharp/VS_Snippets_Winforms/System.ComponentModel.IPropertyChangeExample/CS/Form1.cs#1)] [!code-vb[System.ComponentModel.IPropertyChangeExample#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.ComponentModel.IPropertyChangeExample/VB/Form1.vb#1)] ## Compiling the Code + This example requires: - References to the System, System.Data, System.Drawing, and System.Windows.Forms assemblies. diff --git a/dotnet-desktop-guide/framework/winforms/controls/rendering-a-windows-forms-control.md b/dotnet-desktop-guide/framework/winforms/controls/rendering-a-windows-forms-control.md index 6b0d8a274b..6b61e58f84 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/rendering-a-windows-forms-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/rendering-a-windows-forms-control.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: aae8e1e6-4786-432b-a15e-f4c44760d302 --- # Rendering a Windows Forms Control + Rendering refers to the process of creating a visual representation on a user's screen. Windows Forms uses GDI (the new Windows graphics library) for rendering. The managed classes that provide access to GDI are in the namespace and its subnamespaces. The following elements are involved in control rendering: @@ -25,7 +26,8 @@ Rendering refers to the process of creating a visual representation on a user's - The procedure for freeing graphics resources. ## Drawing Functionality Provided by Control - The base class provides drawing functionality through its event. A control raises the event whenever it needs to update its display. For more information about events in the .NET Framework, see [Handling and Raising Events](https://docs.microsoft.com/dotnet/standard/events/index). + + The base class provides drawing functionality through its event. A control raises the event whenever it needs to update its display. For more information about events in the .NET Framework, see [Handling and Raising Events](/dotnet/standard/events/index). The event data class for the event, , holds the data needed for drawing a control — a handle to a graphics object and a rectangle object that represents the region to draw in. These objects are shown in bold in the following code fragment. @@ -87,9 +89,11 @@ protected virtual void OnPaintBackground(PaintEventArgs pevent); While has an event-like nomenclature and takes the same argument as the `OnPaint` method, is not a true event method. There is no `PaintBackground` event and does not invoke event delegates. When overriding the method, a derived class is not required to invoke the method of its base class. ## GDI+ Basics + The class provides methods for drawing various shapes such as circles, triangles, arcs, and ellipses, as well as methods for displaying text. The namespace and its subnamespaces contain classes that encapsulate graphics elements such as shapes (circles, rectangles, arcs, and others), colors, fonts, brushes, and so on. For more information about GDI, see [Using Managed Graphics Classes](../advanced/using-managed-graphics-classes.md). The essentials of GDI are also described in the [How to: Create a Windows Forms Control That Shows Progress](how-to-create-a-windows-forms-control-that-shows-progress.md). ## Geometry of the Drawing Region + The property of a control specifies the rectangular region available to the control on the user's screen, while the property of specifies the area that is actually painted. (Remember that painting is done in the event method that takes a instance as its argument). A control might need to paint only a portion of its available area, as is the case when a small section of the control's display changes. In those situations, a control developer must compute the actual rectangle to draw in and pass that to . The overloaded versions of that take a or as an argument use that argument to generate the property of . The following code fragment shows how the `FlashTrackBar` custom control computes the rectangular area to draw in. The `client` variable denotes the property. For a complete sample, see [How to: Create a Windows Forms Control That Shows Progress](how-to-create-a-windows-forms-control-that-shows-progress.md). @@ -98,6 +102,7 @@ protected virtual void OnPaintBackground(PaintEventArgs pevent); [!code-vb[System.Windows.Forms.FlashTrackBar#6](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FlashTrackBar/VB/FlashTrackBar.vb#6)] ## Freeing Graphics Resources + Graphics objects are expensive because they use system resources. Such objects include instances of the class as well as instances of , , and other graphics classes. It is important that you create a graphics resource only when you need it and release it soon as you are finished using it. If you create a type that implements the interface, call its method when you are finished with it in order to free resources. The following code fragment shows how the `FlashTrackBar` custom control creates and releases a resource. For the complete source code, see [How to: Create a Windows Forms Control That Shows Progress](how-to-create-a-windows-forms-control-that-shows-progress.md). diff --git a/dotnet-desktop-guide/framework/winforms/controls/run-procedures-at-set-intervals-with-wf-timer-component.md b/dotnet-desktop-guide/framework/winforms/controls/run-procedures-at-set-intervals-with-wf-timer-component.md index 787228ab1a..2446395cd1 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/run-procedures-at-set-intervals-with-wf-timer-component.md +++ b/dotnet-desktop-guide/framework/winforms/controls/run-procedures-at-set-intervals-with-wf-timer-component.md @@ -16,9 +16,10 @@ helpviewer_keywords: ms.assetid: 8025247a-2de4-4d86-b8ab-a8cb8aeab2ea --- # How to: Run Procedures at Set Intervals with the Windows Forms Timer Component + You might sometimes want to create a procedure that runs at specific time intervals until a loop has finished or that runs when a set time interval has elapsed. The component makes such a procedure possible. - This component is designed for a Windows Forms environment. If you need a timer that is suitable for a server environment, see [Introduction to Server-Based Timers](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)). + This component is designed for a Windows Forms environment. If you need a timer that is suitable for a server environment, see [Introduction to Server-Based Timers](/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)). > [!NOTE] > There are some limitations when using the component. For more information, see [Limitations of the Windows Forms Timer Component's Interval Property](limitations-of-the-timer-component-interval-property.md). @@ -39,6 +40,7 @@ You might sometimes want to create a procedure that runs at specific time interv 5. At the appropriate time, set the property to `false` to stop the procedure from running again. Setting the interval to `0` does not cause the timer to stop. ## Example + This first code example tracks the time of day in one-second increments. It uses a , a , and a component on a form. The property is set to 1000 (equal to one second). In the event, the label's caption is set to the current time. When the button is clicked, the property is set to `false`, stopping the timer from updating the label's caption. The following code example requires that you have a form with a control named `Button1`, a control named `Timer1`, and a control named `Label1`. ```vb @@ -144,6 +146,7 @@ private: ``` ## Example + This second code example runs a procedure every 600 milliseconds until a loop has finished. The following code example requires that you have a form with a control named `Button1`, a control named `Timer1`, and a control named `Label1`. ```vb diff --git a/dotnet-desktop-guide/framework/winforms/controls/serializing-collections-designerserializationvisibilityattribute.md b/dotnet-desktop-guide/framework/winforms/controls/serializing-collections-designerserializationvisibilityattribute.md index 0898755369..36003554b9 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/serializing-collections-designerserializationvisibilityattribute.md +++ b/dotnet-desktop-guide/framework/winforms/controls/serializing-collections-designerserializationvisibilityattribute.md @@ -19,7 +19,7 @@ manager: jillfra Your custom controls will sometimes expose a collection as a property. This walkthrough demonstrates how to use the class to control how a collection is serialized at design time. Applying the value to your collection property ensures that the property will be serialized. -To copy the code in this topic as a single listing, see [How to: Serialize Collections of Standard Types with the DesignerSerializationVisibilityAttribute](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/ms171833(v=vs.120)). +To copy the code in this topic as a single listing, see [How to: Serialize Collections of Standard Types with the DesignerSerializationVisibilityAttribute](/previous-versions/visualstudio/visual-studio-2013/ms171833(v=vs.120)). ## Prerequisites @@ -123,11 +123,11 @@ To test the serialization behavior of your control, you will place it on a form Once you know how to serialize a collection of standard types, consider integrating your custom controls more deeply into the design-time environment. The following topics describe how to enhance the design-time integration of your custom controls: -- [Design-Time Architecture](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/c5z9s1h4(v=vs.120)) +- [Design-Time Architecture](/previous-versions/visualstudio/visual-studio-2013/c5z9s1h4(v=vs.120)) - [Attributes in Windows Forms Controls](attributes-in-windows-forms-controls.md) -- [Designer Serialization Overview](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/ms171834(v=vs.120)) +- [Designer Serialization Overview](/previous-versions/visualstudio/visual-studio-2013/ms171834(v=vs.120)) - [Walkthrough: Creating a Windows Forms Control That Takes Advantage of Visual Studio Design-Time Features](creating-a-wf-control-design-time-features.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/sort-and-filter-ado-net-data-with-wf-bindingsource-component.md b/dotnet-desktop-guide/framework/winforms/controls/sort-and-filter-ado-net-data-with-wf-bindingsource-component.md index 8cb808b6dd..ebd3f6442f 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/sort-and-filter-ado-net-data-with-wf-bindingsource-component.md +++ b/dotnet-desktop-guide/framework/winforms/controls/sort-and-filter-ado-net-data-with-wf-bindingsource-component.md @@ -15,10 +15,11 @@ helpviewer_keywords: ms.assetid: 6c206daf-d706-4602-9dbe-435343052063 --- # How to: Sort and Filter ADO.NET Data with the Windows Forms BindingSource Component + You can expose the sorting and filtering capability of control through the and properties. You can apply simple sorting when the underlying data source is an , and you can apply filtering and advanced sorting when the data source is an . The property requires standard ADO.NET syntax: a string representing the name of a column of data in the data source followed by `ASC` or `DESC` to indicate whether the list should be sorted in ascending or descending order. You can set advanced sorting or multiple-column sorting by separating each column with a comma separator. The property takes a string expression. > [!NOTE] -> Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information). +> Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information). ### To filter data with the BindingSource @@ -39,17 +40,19 @@ You can expose the sorting and filtering capability of control, and filters and sorts the displayed data. [!code-csharp[System.Windows.Forms.DataConnectorFilterAndSort#1](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataConnectorFilterAndSort/CS/form1.cs#1)] [!code-vb[System.Windows.Forms.DataConnectorFilterAndSort#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataConnectorFilterAndSort/VB/form1.vb#1)] ## Compiling the Code + To run this example, paste the code into a form that contains a named `BindingSource1` and a named `dataGridView1`. Handle the event for the form and call `InitializeSortedFilteredBindingSource` in the load event handler method. ## See also - - -- [How to: Install Sample Databases](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/8b6y4c7s(v=vs.120)) +- [How to: Install Sample Databases](/previous-versions/visualstudio/visual-studio-2013/8b6y4c7s(v=vs.120)) - [BindingSource Component](bindingsource-component.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/soundplayer-class.md b/dotnet-desktop-guide/framework/winforms/controls/soundplayer-class.md index e1af07425a..a88a72eeae 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/soundplayer-class.md +++ b/dotnet-desktop-guide/framework/winforms/controls/soundplayer-class.md @@ -8,11 +8,13 @@ helpviewer_keywords: ms.assetid: f3945af9-045c-4e2d-b251-377c37ca2d77 --- # SoundPlayer Class + The `SoundPlayer` class enables you to easily include sounds in your applications. You can also use the class to play common system sounds, including a beep. ## In This Section + [SoundPlayer Class Overview](soundplayer-class-overview.md) Introduces the class and its commonly used properties, methods, and events. @@ -35,10 +37,12 @@ The `SoundPlayer` class enables you to easily include sounds in your application Provides code that plays a sound repeatedly. ## Reference + Describes this class and has links to all its members. ## Related Sections + [Windows Forms Controls](index.md) Provides links to topics about the controls designed specifically to work with Windows Forms. @@ -47,4 +51,4 @@ The `SoundPlayer` class enables you to easily include sounds in your application ## See also -- [My.Computer Object](https://docs.microsoft.com/dotnet/visual-basic/language-reference/objects/my-computer-object) +- [My.Computer Object](/dotnet/visual-basic/language-reference/objects/my-computer-object) diff --git a/dotnet-desktop-guide/framework/winforms/controls/splitcontainer-control-overview-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/splitcontainer-control-overview-windows-forms.md index 20ec08c5d0..229969f0ae 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/splitcontainer-control-overview-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/splitcontainer-control-overview-windows-forms.md @@ -8,6 +8,7 @@ helpviewer_keywords: ms.assetid: 6de5a5f7-97a5-402d-be6d-7e2785483db5 --- # SplitContainer Control Overview (Windows Forms) + The Windows Forms control can be thought of as a composite; it is two panels separated by a movable bar. When the mouse pointer is over the bar, the pointer changes shape to show that the bar is movable. > [!IMPORTANT] @@ -47,4 +48,4 @@ The Windows Forms control can be thou - - [SplitContainer Control](splitcontainer-control-windows-forms.md) -- [SplitContainer Control Sample](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2008/0ffz7d1b(v=vs.90)) +- [SplitContainer Control Sample](/previous-versions/visualstudio/visual-studio-2008/0ffz7d1b(v=vs.90)) diff --git a/dotnet-desktop-guide/framework/winforms/controls/statusstrip-control-overview.md b/dotnet-desktop-guide/framework/winforms/controls/statusstrip-control-overview.md index d58f995f60..a3fcae0420 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/statusstrip-control-overview.md +++ b/dotnet-desktop-guide/framework/winforms/controls/statusstrip-control-overview.md @@ -9,13 +9,14 @@ helpviewer_keywords: ms.assetid: c0d9bcbb-f8b8-46ef-bae2-4146b8c8ce99 --- # StatusStrip Control Overview + A control displays information about an object being viewed on a , the object's components, or contextual information that relates to that object's operation within your application. Typically, a control consists of objects, each of which displays text, an icon, or both. The can also contain , , and controls. The default has no panels. To add panels to a , use the method. There is extensive support for handling items and common commands in Visual Studio. - Also see [StatusStrip Items Collection Editor](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233631(v=vs.100)) and [StatusStrip Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233642(v=vs.100)). + Also see [StatusStrip Items Collection Editor](/previous-versions/visualstudio/visual-studio-2010/ms233631(v=vs.100)) and [StatusStrip Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233642(v=vs.100)). Although replaces and extends the control of previous versions, is retained for both backward compatibility and future use if you choose. diff --git a/dotnet-desktop-guide/framework/winforms/controls/statusstrip-control.md b/dotnet-desktop-guide/framework/winforms/controls/statusstrip-control.md index 5d29948447..e10d93c864 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/statusstrip-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/statusstrip-control.md @@ -7,18 +7,21 @@ helpviewer_keywords: ms.assetid: eb1e59da-0a48-4ce5-af7d-13b8e75af4b1 --- # StatusStrip Control + The Windows Forms `StatusStrip` control is used on forms as an area, usually displayed at the bottom of a window, in which an application can display various kinds of status information. `StatusStrip` controls typically have `ToolStripStatusLabel` controls on them that display text or icons to indicate state, or a that graphically displays the completion state of a process. ## In This Section + [StatusStrip Control Overview](statusstrip-control-overview.md) Explains what this control is and its key features and properties. [How to: Use the Spring Property Interactively in a StatusStrip](how-to-use-the-spring-property-interactively-in-a-statusstrip.md) Demonstrates using the `Spring` property to interactively center a `ToolStripStatusLabel` in a `StatusStrip`. - Also see [StatusStrip Items Collection Editor](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233631(v=vs.100)) and [StatusStrip Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233642(v=vs.100)). + Also see [StatusStrip Items Collection Editor](/previous-versions/visualstudio/visual-studio-2010/ms233631(v=vs.100)) and [StatusStrip Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233642(v=vs.100)). ## Reference + Provides reference information on the class and its members. diff --git a/dotnet-desktop-guide/framework/winforms/controls/tablelayoutpanel-control-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/tablelayoutpanel-control-windows-forms.md index a463c50804..26000ecae8 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/tablelayoutpanel-control-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/tablelayoutpanel-control-windows-forms.md @@ -11,9 +11,11 @@ helpviewer_keywords: ms.assetid: f55175c6-424e-4782-a86e-3f79c1550235 --- # TableLayoutPanel Control (Windows Forms) + The control arranges its contents in a grid. Because the layout is performed both at design time and run time, it can change dynamically as the application environment changes. This gives the controls in the panel the ability to proportionally resize, so it can respond to changes such as the parent control resizing or text length changing due to localization. ## In This Section + [TableLayoutPanel Control Overview](tablelayoutpanel-control-overview.md) Introduces the general concepts of the control, which allows you to create a layout with rows and columns. @@ -41,6 +43,7 @@ The control arranges its contents i 4. [Walkthrough: Arranging Controls on Windows Forms Using a TableLayoutPanel](walkthrough-arranging-controls-on-windows-forms-using-a-tablelayoutpanel.md) ## Reference + Provides reference documentation for the control. @@ -51,7 +54,8 @@ The control arranges its contents i Provides reference documentation for the control. ## Related Sections - [Localization](https://docs.microsoft.com/dotnet/standard/globalization-localization/localization) + + [Localization](/dotnet/standard/globalization-localization/localization) Provides an overview of topics relating to localization. - Also see [Localizing Applications](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/z68135h5(v=vs.120)). + Also see [Localizing Applications](/previous-versions/visualstudio/visual-studio-2013/z68135h5(v=vs.120)). diff --git a/dotnet-desktop-guide/framework/winforms/controls/timer-component-overview-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/timer-component-overview-windows-forms.md index b18479d56b..136c32519d 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/timer-component-overview-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/timer-component-overview-windows-forms.md @@ -9,9 +9,11 @@ helpviewer_keywords: ms.assetid: e672c05b-a8b6-4b26-9e4d-9223aa9e3873 --- # Timer Component Overview (Windows Forms) -The Windows Forms is a component that raises an event at regular intervals. This component is designed for a Windows Forms environment. If you need a timer that is suitable for a server environment, see [Introduction to Server-Based Timers](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)). + +The Windows Forms is a component that raises an event at regular intervals. This component is designed for a Windows Forms environment. If you need a timer that is suitable for a server environment, see [Introduction to Server-Based Timers](/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)). ## Key Properties, Methods, and Events + The length of the intervals is defined by the property, whose value is in milliseconds. When the component is enabled, the event is raised every interval. This is where you would add code to be executed. For more information, see [How to: Run Procedures at Set Intervals with the Windows Forms Timer Component](run-procedures-at-set-intervals-with-wf-timer-component.md). The key methods of the component are and , which turn the timer on and off. When the timer is switched off, it resets; there is no way to pause a component. ## See also diff --git a/dotnet-desktop-guide/framework/winforms/controls/toolstrip-technology-summary.md b/dotnet-desktop-guide/framework/winforms/controls/toolstrip-technology-summary.md index fd5924426f..d8e8fbaf4d 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/toolstrip-technology-summary.md +++ b/dotnet-desktop-guide/framework/winforms/controls/toolstrip-technology-summary.md @@ -9,14 +9,17 @@ helpviewer_keywords: ms.assetid: e8d61973-7af9-429f-9df5-05a899c15a7b --- # ToolStrip Technology Summary + This topic summarizes information about the `ToolStrip` control and the classes that support its use. The `ToolStrip` control and its associated classes provide a complete solution for creating toolbars, status bars, and menus. ## Namespaces + ## Background + With the `ToolStrip` control and its associated classes, you can create advanced toolbar functionality that has consistent and professional appearance and behavior. The `ToolStrip` control and classes offer the following improvements over previous controls: - A more consistent event model. @@ -42,6 +45,7 @@ This topic summarizes information about the `ToolStrip` control and the classes The `ToolStrip`, `MenuStrip`, `ContextMenuStrip`, and `StatusStrip` controls replace the previous toolbar, menu, shortcut menu, and status bar controls, although those controls are retained for backward compatibility. ## ToolStrip Classes at a Glance + The following table shows the ToolStrip classes grouped by technology area. |Technology area|Class| @@ -52,38 +56,43 @@ This topic summarizes information about the `ToolStrip` control and the classes |Presentation and rendering|







| ## ToolStrip Design-Time Features + The family of controls provides a rich set of tools and templates for in-place editing and defining the foundation of the user interface so that you can quickly create a working application. ### Task Dialog Boxes + In Visual Studio, clicking the smart tag on a control in the designer displays a task list for convenient access to many frequently used commands. -- [MenuStrip Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233645(v=vs.100)) +- [MenuStrip Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233645(v=vs.100)) -- [ToolStrip Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233648(v=vs.100)) +- [ToolStrip Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233648(v=vs.100)) -- [ContextMenuStrip Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233646(v=vs.100)) +- [ContextMenuStrip Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233646(v=vs.100)) -- [StatusStrip Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233642(v=vs.100)) +- [StatusStrip Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233642(v=vs.100)) -- [ToolStripContainer Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233647(v=vs.100)) +- [ToolStripContainer Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233647(v=vs.100)) ### Items Collection Editors + In Visual Studio, when you click **Edit Items** on the task list or right-click the control and select **Edit Items** in the shortcut menu, the collection editor for the control is displayed. Collection editors let you add, remove, and reorder items that the control contains. You can also view and change the properties for the control and the control's items. -- [MenuStrip Items Collection Editor](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233625(v=vs.100)) +- [MenuStrip Items Collection Editor](/previous-versions/visualstudio/visual-studio-2010/ms233625(v=vs.100)) -- [StatusStrip Items Collection Editor](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233631(v=vs.100)) +- [StatusStrip Items Collection Editor](/previous-versions/visualstudio/visual-studio-2010/ms233631(v=vs.100)) -- [ContextMenuStrip Items Collection Editor](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233641(v=vs.100)) +- [ContextMenuStrip Items Collection Editor](/previous-versions/visualstudio/visual-studio-2010/ms233641(v=vs.100)) -- [ToolStrip Items Collection Editor](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233643(v=vs.100)) +- [ToolStrip Items Collection Editor](/previous-versions/visualstudio/visual-studio-2010/ms233643(v=vs.100)) ## Hosting Controls + The class provides built-in wrappers for , , and controls. You can also host any other existing or COM control in a . For an example of control hosting, see [How to: Wrap a Windows Forms Control with ToolStripControlHost](how-to-wrap-a-windows-forms-control-with-toolstripcontrolhost.md). ## Rendering + classes implement a rendering scheme that is significantly different from other Windows Forms controls. With this scheme, you can easily apply styles and themes. To apply a style to a and all the objects it contains, you do not have to handle the event for each item. Instead, you can set the property to one of the values other than . Alternatively, you can set the directly to any class that inherits from the class. Setting this property automatically sets the . @@ -93,9 +102,11 @@ This topic summarizes information about the `ToolStrip` control and the classes For examples of rendering, see [How to: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms](create-and-set-a-custom-renderer-for-the-toolstrip-control-in-wf.md). ## Styles and Themes + and associated classes provide an easy way to support visual styles and custom appearance that do not require overriding the methods for each item. Use the and the and properties. ## Rafting and Docking + You can raft, dock, or absolutely position controls. items are laid out by the of the container. *Rafting* is the ability of toolbars to share horizontal or vertical space. A Windows form can have a that in turn has panels on the form's left, right, top, and bottom sides for positioning and rafting , , and controls. Multiple controls stack vertically if you put them in the left or right . They stack horizontally if you put them in the top or bottom . You can use the central of the to position traditional controls on the form. diff --git a/dotnet-desktop-guide/framework/winforms/controls/toolstripcontainer-control.md b/dotnet-desktop-guide/framework/winforms/controls/toolstripcontainer-control.md index b7adbde686..98e3fa2fd6 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/toolstripcontainer-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/toolstripcontainer-control.md @@ -8,11 +8,13 @@ helpviewer_keywords: ms.assetid: 378fa5b4-38e1-46f4-8e5c-d0c19dcd0200 --- # ToolStripContainer Control + controls feature built-in rafting (sharing of horizontal or vertical space within the tool area when docked) by using the . The topics in this section describe the concepts and techniques that you can use to build features into your applications. ## In This Section + [ToolStripContainer Control Overview](toolstripcontainer-control-overview.md) Provides topics that describe the purpose and main concepts of the Windows Forms control. @@ -23,15 +25,17 @@ ms.assetid: 378fa5b4-38e1-46f4-8e5c-d0c19dcd0200 Demonstrates adding a control to the . ## Reference + Provides reference documentation for the control. Provides reference documentation for the of a control. - Also see [ToolStripContainer Tasks Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233647(v=vs.100)). + Also see [ToolStripContainer Tasks Dialog Box](/previous-versions/visualstudio/visual-studio-2010/ms233647(v=vs.100)). ## Related Sections + Provides reference documentation for the control. diff --git a/dotnet-desktop-guide/framework/winforms/controls/toolstrippanel-control-overview.md b/dotnet-desktop-guide/framework/winforms/controls/toolstrippanel-control-overview.md index 060ea0cdc7..768f5f89dc 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/toolstrippanel-control-overview.md +++ b/dotnet-desktop-guide/framework/winforms/controls/toolstrippanel-control-overview.md @@ -9,6 +9,7 @@ helpviewer_keywords: ms.assetid: ce54a60c-5eba-4b4c-bd77-cf0748a666cc --- # ToolStripPanel Control Overview + A provides a single area for positioning and rafting , , and controls. Multiple controls stack vertically or horizontally depending on the of the . ### Important ToolStripPanel Members @@ -26,4 +27,4 @@ A provides a single area for position - - -- [ToolStrip Sample](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2008/ms181005(v=vs.90)) +- [ToolStrip Sample](/previous-versions/visualstudio/visual-studio-2008/ms181005(v=vs.90)) diff --git a/dotnet-desktop-guide/framework/winforms/controls/troubleshooting-control-and-component-authoring.md b/dotnet-desktop-guide/framework/winforms/controls/troubleshooting-control-and-component-authoring.md index fc7e3ffe5e..e9c0368b8e 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/troubleshooting-control-and-component-authoring.md +++ b/dotnet-desktop-guide/framework/winforms/controls/troubleshooting-control-and-component-authoring.md @@ -97,7 +97,7 @@ For more information about debugging, see [Debugging in Visual Studio](/visualst ## Event Is Raised Twice in Inherited Control or Component -This is likely due to a duplicated `Handles` clause. For more information, see [Troubleshooting Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers). +This is likely due to a duplicated `Handles` clause. For more information, see [Troubleshooting Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers). ## Design-Time Error: "Failed to Create Component 'Component Name'" diff --git a/dotnet-desktop-guide/framework/winforms/controls/varieties-of-custom-controls.md b/dotnet-desktop-guide/framework/winforms/controls/varieties-of-custom-controls.md index 185f0ee386..5cea8cded3 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/varieties-of-custom-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/varieties-of-custom-controls.md @@ -13,14 +13,16 @@ helpviewer_keywords: ms.assetid: 3cea09e5-4344-4ccb-9858-b66ccac210ff --- # Varieties of Custom Controls + With the .NET Framework, you can develop and implement new controls. You can extend the functionality of the familiar user control as well as existing controls through inheritance. You can also write custom controls that perform their own painting. Deciding which kind of control to create can be confusing. This topic highlights the differences among the various kinds of controls from which you can inherit, and provides you with information about how to choose a particular kind of control for your project. > [!NOTE] -> For information about authoring a control to use on Web Forms, see [Developing Custom ASP.NET Server Controls](https://docs.microsoft.com/previous-versions/aspnet/zt27tfhy(v=vs.100)). +> For information about authoring a control to use on Web Forms, see [Developing Custom ASP.NET Server Controls](/previous-versions/aspnet/zt27tfhy(v=vs.100)). ## Base Control Class + The class is the base class for Windows Forms controls. It provides the infrastructure required for visual display in Windows Forms applications. The class performs the following tasks to provide visual display in Windows Forms applications: @@ -40,9 +42,11 @@ With the .NET Framework, you can develop and implement new controls. You can ext Because so much of the infrastructure is provided by the base class, it is relatively easy to develop your own Windows Forms controls. ## Kinds of Controls + Windows Forms supports three kinds of user-defined controls: *composite*, *extended*, and *custom*. The following sections describe each kind of control and give recommendations for choosing the kind to use in your projects. ### Composite Controls + A composite control is a collection of Windows Forms controls encapsulated in a common container. This kind of control is sometimes called a *user control*. The contained controls are called *constituent controls*. A composite control holds all of the inherent functionality associated with each of the contained Windows Forms controls and enables you to selectively expose and bind their properties. A composite control also provides a great deal of default keyboard handling functionality with no extra development effort on your part. @@ -58,6 +62,7 @@ With the .NET Framework, you can develop and implement new controls. You can ext - You want to combine the functionality of several Windows Forms controls into a single reusable unit. ### Extended Controls + You can derive an inherited control from any existing Windows Forms control. With this approach, you can retain all of the inherent functionality of a Windows Forms control, and then extend that functionality by adding custom properties, methods, or other features. With this option, you can override the base control's paint logic, and then extend its user interface by changing its appearance. For example, you can create a control derived from the control that tracks how many times a user has clicked it. @@ -73,6 +78,7 @@ With the .NET Framework, you can develop and implement new controls. You can ext - You do not need a custom graphical user interface, or you want to design a new graphical user interface for an existing control. ### Custom Controls + Another way to create a control is to create one substantially from the beginning by inheriting from . The class provides all of the basic functionality required by controls, including mouse and keyboard handling events, but no control-specific functionality or graphical interface. Creating a control by inheriting from the class requires much more thought and effort than inheriting from or an existing Windows Forms control. Because a great deal of implementation is left for you, your control can have greater flexibility than a composite or extended control, and you can tailor your control to suit your exact needs. @@ -90,20 +96,23 @@ With the .NET Framework, you can develop and implement new controls. You can ext - You need to implement custom functionality that is not available through standard controls. ### ActiveX Controls + Although the Windows Forms infrastructure has been optimized to host Windows Forms controls, you can still use ActiveX controls. There is support for this task in Visual Studio. For more information, see [How to: Add ActiveX Controls to Windows Forms](how-to-add-activex-controls-to-windows-forms.md). ### Windowless Controls + The Microsoft Visual Basic® 6.0and ActiveX technologies support *windowless* controls. Windowless controls are not supported in Windows Forms. ## Custom Design Experience + If you need to implement a custom design-time experience, you can author your own designer. For composite controls, derive your custom designer class from the or the classes. For extended and custom controls, derive your custom designer class from the class. - Use the to associate your control with your designer. For more information, see [Extending Design-Time Support](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) and [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)). + Use the to associate your control with your designer. For more information, see [Extending Design-Time Support](/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) and [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)). ## See also - [Developing Custom Windows Forms Controls with the .NET Framework](developing-custom-windows-forms-controls.md) - [How to: Develop a Simple Windows Forms Control](how-to-develop-a-simple-windows-forms-control.md) - [Developing a Composite Windows Forms Control](developing-a-composite-windows-forms-control.md) -- [Extending Design-Time Support](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) -- [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)) +- [Extending Design-Time Support](/previous-versions/visualstudio/visual-studio-2013/37899azc(v=vs.120)) +- [How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features](/previous-versions/visualstudio/visual-studio-2013/307hck25(v=vs.120)) diff --git a/dotnet-desktop-guide/framework/winforms/controls/virtual-mode-with-just-in-time-data-loading-in-the-datagrid.md b/dotnet-desktop-guide/framework/winforms/controls/virtual-mode-with-just-in-time-data-loading-in-the-datagrid.md index e6e6e82089..7de1381571 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/virtual-mode-with-just-in-time-data-loading-in-the-datagrid.md +++ b/dotnet-desktop-guide/framework/winforms/controls/virtual-mode-with-just-in-time-data-loading-in-the-datagrid.md @@ -14,13 +14,16 @@ helpviewer_keywords: ms.assetid: 33825f92-7a22-40ee-86d9-9a2ed1ead7b7 --- # How to: Implement Virtual Mode with Just-In-Time Data Loading in the Windows Forms DataGridView Control + The following code example shows how to use virtual mode in the control with a data cache that loads data from a server only when it is needed. This example is described in detail in [Implementing Virtual Mode with Just-In-Time Data Loading in the Windows Forms DataGridView Control](implementing-virtual-mode-jit-data-loading-in-the-datagrid.md). ## Example + [!code-csharp[System.Windows.Forms.DataGridView.Virtual_lazyloading#000](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.Virtual_lazyloading/CS/lazyloading.cs#000)] [!code-vb[System.Windows.Forms.DataGridView.Virtual_lazyloading#000](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.Virtual_lazyloading/VB/lazyloading.vb#000)] ## Compiling the Code + This example requires: - References to the System, System.Data, System.Xml, and System.Windows.Forms assemblies. @@ -28,7 +31,8 @@ The following code example shows how to use virtual mode in the arranges its contents in a speci The arranges its contents in a grid, providing functionality similar to the HTML \ element. The control allows you to place controls in a grid layout without requiring you to precisely specify the position of each individual control. Its cells are arranged in rows and columns, and these can have different sizes. Cells can be merged across rows and columns. Cells can contain anything a form can contain and behave in most other respects as containers. -The control also provides a proportional resizing capability at run time, so your layout can change smoothly as your form is resized. This makes the control well suited for purposes such as data-entry forms and localized applications. For more information, see [Walkthrough: Creating a Resizable Windows Form for Data Entry](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/991eahec(v=vs.100)) and [Walkthrough: Creating a Localizable Windows Form](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100)). +The control also provides a proportional resizing capability at run time, so your layout can change smoothly as your form is resized. This makes the control well suited for purposes such as data-entry forms and localized applications. For more information, see [Walkthrough: Creating a Resizable Windows Form for Data Entry](/previous-versions/visualstudio/visual-studio-2010/991eahec(v=vs.100)) and [Walkthrough: Creating a Localizable Windows Form](/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100)). In general, you should not use a control as a container for the whole layout. Use controls to provide proportional resizing capabilities to parts of the layout. @@ -188,8 +188,8 @@ You can achieve a complex layout using a combination of layout panels and contro - - [Walkthrough: Arranging Controls on Windows Forms Using a FlowLayoutPanel](walkthrough-arranging-controls-on-windows-forms-using-a-flowlayoutpanel.md) - [Walkthrough: Arranging Controls on Windows Forms Using Snaplines](walkthrough-arranging-controls-on-windows-forms-using-snaplines.md) -- [Walkthrough: Creating a Resizable Windows Form for Data Entry](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/991eahec(v=vs.100)) -- [Walkthrough: Creating a Localizable Windows Form](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100)) +- [Walkthrough: Creating a Resizable Windows Form for Data Entry](/previous-versions/visualstudio/visual-studio-2010/991eahec(v=vs.100)) +- [Walkthrough: Creating a Localizable Windows Form](/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100)) - [Best Practices for the TableLayoutPanel Control](best-practices-for-the-tablelayoutpanel-control.md) - [AutoSize Property Overview](autosize-property-overview.md) - [How to: Dock Controls on Windows Forms](how-to-dock-controls-on-windows-forms.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-automatically-populating-the-toolbox-with-custom-components.md b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-automatically-populating-the-toolbox-with-custom-components.md index 315e4a8954..cde68f6ce5 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-automatically-populating-the-toolbox-with-custom-components.md +++ b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-automatically-populating-the-toolbox-with-custom-components.md @@ -9,7 +9,7 @@ ms.assetid: 2fa1e3e8-6b9f-42b2-97c0-2be57444dba4 --- # Walkthrough: Automatically Populating the Toolbox with Custom Components -If your components are defined by a project in the currently open solution, they will automatically appear in the **Toolbox**, with no action required by you. You can also manually populate the **Toolbox** with your custom components by using the [Choose Toolbox Items Dialog Box (Visual Studio)](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/dyca0t6t(v=vs.100)), but the **Toolbox** takes account of items in your solution's build outputs with all the following characteristics: +If your components are defined by a project in the currently open solution, they will automatically appear in the **Toolbox**, with no action required by you. You can also manually populate the **Toolbox** with your custom components by using the [Choose Toolbox Items Dialog Box (Visual Studio)](/previous-versions/visualstudio/visual-studio-2010/dyca0t6t(v=vs.100)), but the **Toolbox** takes account of items in your solution's build outputs with all the following characteristics: - Implements ; @@ -38,7 +38,7 @@ When you are finished, you will see that the **Toolbox** is populated with a com 2. Add a new component to the project. Call it `DemoComponent`. - For more information, see [How to: Add New Project Items](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/w0572c5b(v=vs.100)). + For more information, see [How to: Add New Project Items](/previous-versions/visualstudio/visual-studio-2010/w0572c5b(v=vs.100)). 3. Build the project. @@ -67,7 +67,7 @@ The **Toolbox** takes account of the components in each loaded project, and when 1. Unload the project from the solution. - For more information about unloading projects, see [How to: Unload and Reload Projects](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/tt479x1t(v=vs.100)). If you are prompted to save, choose **Yes**. + For more information about unloading projects, see [How to: Unload and Reload Projects](/previous-versions/visualstudio/visual-studio-2010/tt479x1t(v=vs.100)). If you are prompted to save, choose **Yes**. 2. Add a new **Windows Application** project to the solution. Open the form in the **Designer**. @@ -83,7 +83,7 @@ This walkthrough demonstrates that the **Toolbox** takes account of a project's ## See also -- [General, Windows Forms Designer, Options Dialog Box](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/5aazxs78(v=vs.100)) -- [How to: Manipulate Toolbox Tabs](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/66kwe227(v=vs.100)) -- [Choose Toolbox Items Dialog Box (Visual Studio)](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/dyca0t6t(v=vs.100)) +- [General, Windows Forms Designer, Options Dialog Box](/previous-versions/visualstudio/visual-studio-2010/5aazxs78(v=vs.100)) +- [How to: Manipulate Toolbox Tabs](/previous-versions/visualstudio/visual-studio-2010/66kwe227(v=vs.100)) +- [Choose Toolbox Items Dialog Box (Visual Studio)](/previous-versions/visualstudio/visual-studio-2010/dyca0t6t(v=vs.100)) - [Putting Controls on Windows Forms](putting-controls-on-windows-forms.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-creating-a-professionally-styled-toolstrip-control.md b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-creating-a-professionally-styled-toolstrip-control.md index 18ab2f9abe..1b6ad0f13e 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-creating-a-professionally-styled-toolstrip-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-creating-a-professionally-styled-toolstrip-control.md @@ -37,7 +37,7 @@ You'll need Visual Studio to complete this walkthrough. 2. In **Solution Explorer**, delete the project's default control by deleting the source file named "UserControl1.cs" or "UserControl1.vb", depending on your language of choice. - For more information, see [How to: Remove, Delete, and Exclude Items](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/0ebzhwsk(v=vs.100)). + For more information, see [How to: Remove, Delete, and Exclude Items](/previous-versions/visualstudio/visual-studio-2010/0ebzhwsk(v=vs.100)). 3. Add a new item to the **StackViewLibrary** project. Give the new source file a base name of `StackView`. @@ -122,7 +122,7 @@ Two events are important to make the `StackView` control behave correctly. Handl ## Define icons -Each `StackView` button has an associated icon. For convenience, each icon is represented as a Base64-encoded string, which is deserialized before a is created from it. In a production environment, you store bitmap data as a resource, and your icons appear in the Windows Forms Designer. For more information, see [How to: Add Background Images to Windows Forms](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/dff9f95f(v=vs.100)). +Each `StackView` button has an associated icon. For convenience, each icon is represented as a Base64-encoded string, which is deserialized before a is created from it. In a production environment, you store bitmap data as a resource, and your icons appear in the Windows Forms Designer. For more information, see [How to: Add Background Images to Windows Forms](/previous-versions/visualstudio/visual-studio-2010/dff9f95f(v=vs.100)). 1. In the Code Editor, insert the following code into the `StackView` class definition. This code initializes the bitmaps for the icons. diff --git a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-creating-an-mdi-form-with-menu-merging-and-toolstrip-controls.md b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-creating-an-mdi-form-with-menu-merging-and-toolstrip-controls.md index e84d36005f..24576ae6f0 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-creating-an-mdi-form-with-menu-merging-and-toolstrip-controls.md +++ b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-creating-an-mdi-form-with-menu-merging-and-toolstrip-controls.md @@ -92,7 +92,7 @@ In this procedure, you will define a separate child form class that has its own 1. Add a new form named `ChildForm` to the project. - For more information, see [How to: Add Windows Forms to a Project](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/y2xxdce3(v=vs.100)). + For more information, see [How to: Add Windows Forms to a Project](/previous-versions/visualstudio/visual-studio-2010/y2xxdce3(v=vs.100)). 2. From the **Toolbox**, drag a control onto the child form. @@ -100,7 +100,7 @@ In this procedure, you will define a separate child form class that has its own 4. In the **Items Collection Editor** dialog box, add a new named **ChildMenuItem** to the child menu. - For more information, see [ToolStrip Items Collection Editor](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233643(v=vs.100)). + For more information, see [ToolStrip Items Collection Editor](/previous-versions/visualstudio/visual-studio-2010/ms233643(v=vs.100)). ## Test the form diff --git a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-implementing-a-form-that-uses-a-background-operation.md b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-implementing-a-form-that-uses-a-background-operation.md index 08e6c875ca..f8a17bb14e 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-implementing-a-form-that-uses-a-background-operation.md +++ b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-implementing-a-form-that-uses-a-background-operation.md @@ -46,7 +46,7 @@ For a complete listing of the code used in this example, see [How to: Implement 5. Rename the first control `startAsyncButton` and set the property to `Start Async`. Rename the second control `cancelAsyncButton`, and set the property to `Cancel Async`. Set its property to `false`. -6. Create an event handler for both of the controls' events. For details, see [How to: Create Event Handlers Using the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/zwwsdtbk(v=vs.100)). +6. Create an event handler for both of the controls' events. For details, see [How to: Create Event Handlers Using the Designer](/previous-versions/visualstudio/visual-studio-2010/zwwsdtbk(v=vs.100)). 7. Drag a control from the **Toolbox** onto the form and rename it `resultLabel`. @@ -62,7 +62,7 @@ From the **Components** tab of the **Toolbox**, drag a component's asynchronous events. The time-consuming operation that will run in the background, which computes Fibonacci numbers, is called by one of these event handlers. -1. In the **Properties** window, with the component still selected, click the **Events** button. Double-click the and events to create event handlers. For more information about how to use event handlers, see [How to: Create Event Handlers Using the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/zwwsdtbk(v=vs.100)). +1. In the **Properties** window, with the component still selected, click the **Events** button. Double-click the and events to create event handlers. For more information about how to use event handlers, see [How to: Create Event Handlers Using the Designer](/previous-versions/visualstudio/visual-studio-2010/zwwsdtbk(v=vs.100)). 2. Create a new method, called `ComputeFibonacci`, in your form. This method does the actual work, and it will run in the background. This code demonstrates the recursive implementation of the Fibonacci algorithm, which is notably inefficient, taking exponentially longer time to complete for larger numbers. It is used here for illustrative purposes, to show an operation that can introduce long delays in your application. @@ -146,17 +146,17 @@ Now that you have implemented a form that uses a [!CAUTION] - > When using multithreading of any sort, you potentially expose yourself to very serious and complex bugs. Consult the [Managed Threading Best Practices](https://docs.microsoft.com/dotnet/standard/threading/managed-threading-best-practices) before implementing any solution that uses multithreading. + > When using multithreading of any sort, you potentially expose yourself to very serious and complex bugs. Consult the [Managed Threading Best Practices](/dotnet/standard/threading/managed-threading-best-practices) before implementing any solution that uses multithreading. ## See also - -- [Managed Threading](https://docs.microsoft.com/dotnet/standard/threading/index) -- [Managed Threading Best Practices](https://docs.microsoft.com/dotnet/standard/threading/managed-threading-best-practices) -- [Event-based Asynchronous Pattern Overview](https://docs.microsoft.com/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) +- [Managed Threading](/dotnet/standard/threading/index) +- [Managed Threading Best Practices](/dotnet/standard/threading/managed-threading-best-practices) +- [Event-based Asynchronous Pattern Overview](/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview) - [How to: Implement a Form That Uses a Background Operation](how-to-implement-a-form-that-uses-a-background-operation.md) - [Walkthrough: Running an Operation in the Background](walkthrough-running-an-operation-in-the-background.md) - [BackgroundWorker Component](backgroundworker-component.md) diff --git a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-inheriting-from-a-windows-forms-control-with-visual-csharp.md b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-inheriting-from-a-windows-forms-control-with-visual-csharp.md index 54244ac994..5ba801671c 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-inheriting-from-a-windows-forms-control-with-visual-csharp.md +++ b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-inheriting-from-a-windows-forms-control-with-visual-csharp.md @@ -24,7 +24,7 @@ When you create a new project, you specify its name in order to set the root nam 1. In Visual Studio, create a new **Windows Forms Control Library** project, and name it **ValueButtonLib**. - The project name, `ValueButtonLib`, is also assigned to the root namespace by default. The root namespace is used to qualify the names of components in the assembly. For example, if two assemblies provide components named `ValueButton`, you can specify your `ValueButton` component using `ValueButtonLib.ValueButton`. For more information, see [Namespaces](https://docs.microsoft.com/dotnet/csharp/programming-guide/namespaces/index). + The project name, `ValueButtonLib`, is also assigned to the root namespace by default. The root namespace is used to qualify the names of components in the assembly. For example, if two assemblies provide components named `ValueButton`, you can specify your `ValueButton` component using `ValueButtonLib.ValueButton`. For more information, see [Namespaces](/dotnet/csharp/programming-guide/namespaces/index). 2. In **Solution Explorer**, right-click **UserControl1.cs**, then choose **Rename** from the shortcut menu. Change the file name to **ValueButton.cs**. Click the **Yes** button when you are asked if you want to rename all references to the code element '`UserControl1`'. diff --git a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-running-an-operation-in-the-background.md b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-running-an-operation-in-the-background.md index 51f2f0df67..dde976d127 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-running-an-operation-in-the-background.md +++ b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-running-an-operation-in-the-background.md @@ -90,7 +90,7 @@ For a complete listing of the code used in this example, see [How to: Run an Ope - Implement a form that reports progress as an asynchronous operation proceeds. For more information, see [How to: Implement a Form That Uses a Background Operation](how-to-implement-a-form-that-uses-a-background-operation.md). -- Implement a class that supports the Asynchronous Pattern for Components. For more information, see [Implementing the Event-based Asynchronous Pattern](https://docs.microsoft.com/dotnet/standard/asynchronous-programming-patterns/implementing-the-event-based-asynchronous-pattern). +- Implement a class that supports the Asynchronous Pattern for Components. For more information, see [Implementing the Event-based Asynchronous Pattern](/dotnet/standard/asynchronous-programming-patterns/implementing-the-event-based-asynchronous-pattern). ## See also diff --git a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-updating-status-bar-information-at-run-time.md b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-updating-status-bar-information-at-run-time.md index 9ff13e0d25..b199941bc0 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-updating-status-bar-information-at-run-time.md +++ b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-updating-status-bar-information-at-run-time.md @@ -13,6 +13,7 @@ helpviewer_keywords: ms.assetid: cc2abb06-c082-49f7-a5a3-2fd1bbcb58d1 --- # Walkthrough: Updating Status Bar Information at Run Time + > [!IMPORTANT] > The and controls replace and add functionality to the and controls; however, the and controls are retained for both backward compatibility and future use, if you choose. @@ -33,7 +34,7 @@ ms.assetid: cc2abb06-c082-49f7-a5a3-2fd1bbcb58d1 5. Add a Windows Forms component to the form. > [!NOTE] - > The Windows Forms component is designed for a Windows Forms environment. If you need a timer that is suitable for a server environment, see [Introduction to Server-Based Timers](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)). + > The Windows Forms component is designed for a Windows Forms environment. If you need a timer that is suitable for a server environment, see [Introduction to Server-Based Timers](/previous-versions/visualstudio/visual-studio-2008/tb9yt5e6(v=vs.90)). 6. Set the property to `true`. diff --git a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-validating-data-in-the-windows-forms-datagridview-control.md b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-validating-data-in-the-windows-forms-datagridview-control.md index fb5765c4ac..259ab709f9 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/walkthrough-validating-data-in-the-windows-forms-datagridview-control.md +++ b/dotnet-desktop-guide/framework/winforms/controls/walkthrough-validating-data-in-the-windows-forms-datagridview-control.md @@ -45,7 +45,7 @@ In order to complete this walkthrough, you will need: This code example uses a `GetData` method that returns a populated object. Be sure that you set the `connectionString` variable to a value that is appropriate for your database. > [!IMPORTANT] - > Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication, also known as integrated security, is a more secure way to control access to a database. For more information, see [Protecting Connection Information](https://docs.microsoft.com/dotnet/framework/data/adonet/protecting-connection-information). + > Storing sensitive information, such as a password, within the connection string can affect the security of your application. Using Windows Authentication, also known as integrated security, is a more secure way to control access to a database. For more information, see [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information). [!code-csharp[System.Windows.Forms.DataGridViewDataValidation#30](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewDataValidation/CS/datavalidation.cs#30)] [!code-vb[System.Windows.Forms.DataGridViewDataValidation#30](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewDataValidation/VB/datavalidation.vb#30)] @@ -93,4 +93,4 @@ This application gives you a basic understanding of the control is designed to work in full trust only. The HTML content displayed in the control can come from external Web servers and may contain unmanaged code in the form of scripts or Web controls. If you use the control in this situation, the control is no less secure than Internet Explorer would be, but the managed control does not prevent such unmanaged code from running. - For more information about security issues relating to the underlying ActiveX `WebBrowser` control, see [WebBrowser Control](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)). + For more information about security issues relating to the underlying ActiveX `WebBrowser` control, see [WebBrowser Control](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)). ## See also - - [WebBrowser Control Overview](webbrowser-control-overview.md) -- [WebBrowser Control](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)) +- [WebBrowser Control](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)) diff --git a/dotnet-desktop-guide/framework/winforms/creating-event-handlers-in-windows-forms.md b/dotnet-desktop-guide/framework/winforms/creating-event-handlers-in-windows-forms.md index 8f99590782..94c4822f69 100644 --- a/dotnet-desktop-guide/framework/winforms/creating-event-handlers-in-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/creating-event-handlers-in-windows-forms.md @@ -31,13 +31,13 @@ An event handler is a procedure in your code that determines what actions are pe [Order of Events in Windows Forms](order-of-events-in-windows-forms.md)\ Describes the order in which events are raised in Windows Forms controls. - [How to: Create Event Handlers Using the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/zwwsdtbk(v=vs.100)) + [How to: Create Event Handlers Using the Designer](/previous-versions/visualstudio/visual-studio-2010/zwwsdtbk(v=vs.100)) Describes how to use the Windows Forms Designer to create event handlers. ## Related Sections - [Events](https://docs.microsoft.com/dotnet/standard/events/index)\ + [Events](/dotnet/standard/events/index)\ Provides links to topics on handling and raising events using the .NET Framework. - [Troubleshooting Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers)\ + [Troubleshooting Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers)\ Lists common issues that occur with event handlers in inherited components. diff --git a/dotnet-desktop-guide/framework/winforms/data-sources-supported-by-windows-forms.md b/dotnet-desktop-guide/framework/winforms/data-sources-supported-by-windows-forms.md index 64cbcd8c7c..8cb386561b 100644 --- a/dotnet-desktop-guide/framework/winforms/data-sources-supported-by-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/data-sources-supported-by-windows-forms.md @@ -17,9 +17,11 @@ helpviewer_keywords: ms.assetid: 3d2c43f6-462b-4d35-9c86-13e9afe012e1 --- # Data Sources Supported by Windows Forms + Traditionally, data binding has been used within applications to take advantage of data stored in databases. With Windows Forms data binding, you can access data from databases as well as data in other structures, such as arrays and collections, so long as certain minimum requirements have been met. ## Structures to Bind To + In Windows Forms, you can bind to a wide variety of structures, from simple objects (simple binding) to complex lists such as ADO.NET data tables (complex binding). For simple binding, Windows Forms supports binding to the public properties on the simple object. Windows Forms list-based binding generally requires that the object support the interface or the interface. Additionally, if you are binding with through a component, you can bind to an object that supports the interface. For more information about interfaces related to data binding, see [Interfaces Related to Data Binding](interfaces-related-to-data-binding.md). The following list shows the structures you can bind to in Windows Forms. @@ -31,7 +33,7 @@ Traditionally, data binding has been used within applications to take advantage Windows Forms supports data binding control properties to public properties on the instance of an object using the type. Windows Forms also supports binding list based controls, such as a to an object instance when a is used. array or collection - To act as a data source, a list must implement the interface; one example would be an array that is an instance of the class. For more information on arrays, see [How to: Create an Array of Objects (Visual Basic)](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/487y7874(v=vs.100)). + To act as a data source, a list must implement the interface; one example would be an array that is an instance of the class. For more information on arrays, see [How to: Create an Array of Objects (Visual Basic)](/previous-versions/visualstudio/visual-studio-2010/487y7874(v=vs.100)). In general, you should use when you create lists of objects for data binding. is a generic version of the interface. The interface extends the interface by adding properties, methods and events necessary for two-way data binding. diff --git a/dotnet-desktop-guide/framework/winforms/events-overview-windows-forms.md b/dotnet-desktop-guide/framework/winforms/events-overview-windows-forms.md index 34925561c6..4051e80954 100644 --- a/dotnet-desktop-guide/framework/winforms/events-overview-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/events-overview-windows-forms.md @@ -11,6 +11,7 @@ helpviewer_keywords: ms.assetid: 814a6a43-a312-4791-88d8-f75f9a4f8c4c --- # Events Overview (Windows Forms) + An event is an action which you can respond to, or "handle," in code. Events can be generated by a user action, such as clicking the mouse or pressing a key; by program code; or by the system. Event-driven applications execute code in response to an event. Each form and control exposes a predefined set of events that you can program against. If one of these events occurs and there is code in the associated event handler, that code is invoked. @@ -20,14 +21,15 @@ An event is an action which you can respond to, or "handle," in code. Events can > [!NOTE] > Many events occur in conjunction with other events. For example, in the course of the event occurring, the , , and events occur. - For information about how to raise and consume an event, see [Events](https://docs.microsoft.com/dotnet/standard/events/index). + For information about how to raise and consume an event, see [Events](/dotnet/standard/events/index). ## Delegates and Their Role + Delegates are classes commonly used within the .NET Framework to build event-handling mechanisms. Delegates roughly equate to function pointers, commonly used in Visual C++ and other object-oriented languages. Unlike function pointers however, delegates are object-oriented, type-safe, and secure. In addition, where a function pointer contains only a reference to a particular function, a delegate consists of a reference to an object, and references to one or more methods within the object. - This event model uses *delegates* to bind events to the methods that are used to handle them. The delegate enables other classes to register for event notification by specifying a handler method. When the event occurs, the delegate calls the bound method. For more information about how to define delegates, see [Events](https://docs.microsoft.com/dotnet/standard/events/index). + This event model uses *delegates* to bind events to the methods that are used to handle them. The delegate enables other classes to register for event notification by specifying a handler method. When the event occurs, the delegate calls the bound method. For more information about how to define delegates, see [Events](/dotnet/standard/events/index). -Delegates can be bound to a single method or to multiple methods, referred to as multicasting. When creating a delegate for an event, you (or the Windows) typically create a multicast event. A rare exception might be an event that results in a specific procedure (such as displaying a dialog box) that would not logically repeat multiple times per event. For information about how to create a multicast delegate, see [How to combine delegates (Multicast Delegates)](https://docs.microsoft.com/dotnet/csharp/programming-guide/delegates/how-to-combine-delegates-multicast-delegates). +Delegates can be bound to a single method or to multiple methods, referred to as multicasting. When creating a delegate for an event, you (or the Windows) typically create a multicast event. A rare exception might be an event that results in a specific procedure (such as displaying a dialog box) that would not logically repeat multiple times per event. For information about how to create a multicast delegate, see [How to combine delegates (Multicast Delegates)](/dotnet/csharp/programming-guide/delegates/how-to-combine-delegates-multicast-delegates). A multicast delegate maintains an invocation list of the methods it is bound to. The multicast delegate supports a method to add a method to the invocation list and a method to remove it. diff --git a/dotnet-desktop-guide/framework/winforms/high-dpi-support-in-windows-forms.md b/dotnet-desktop-guide/framework/winforms/high-dpi-support-in-windows-forms.md index db79452cea..4b6cffee10 100644 --- a/dotnet-desktop-guide/framework/winforms/high-dpi-support-in-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/high-dpi-support-in-windows-forms.md @@ -43,7 +43,7 @@ In addition, to configure high DPI support in your Windows Forms application, yo - Enable per-monitor DPI awareness in the *app.config* file. - Windows Forms introduces a new [``](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/winforms/index) element to support new features and customizations added starting with the .NET Framework 4.7. To take advantage of the new features that support high DPI, add the following to your application configuration file. + Windows Forms introduces a new [``](/dotnet/framework/configure-apps/file-schema/winforms/index) element to support new features and customizations added starting with the .NET Framework 4.7. To take advantage of the new features that support high DPI, add the following to your application configuration file. ```xml @@ -78,7 +78,7 @@ Setting the `DpiAwareness` value to `PerMonitorV2` enables all high DPI awarenes ``` -For a list of individual keys and their values, see [Windows Forms Add Configuration Element](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/winforms/windows-forms-add-configuration-element). +For a list of individual keys and their values, see [Windows Forms Add Configuration Element](/dotnet/framework/configure-apps/file-schema/winforms/windows-forms-add-configuration-element). ## New DPI change events @@ -126,5 +126,5 @@ Console.WriteLine(AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName); ## See also -- [Windows Forms Add Configuration Element](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/winforms/windows-forms-add-configuration-element) +- [Windows Forms Add Configuration Element](/dotnet/framework/configure-apps/file-schema/winforms/windows-forms-add-configuration-element) - [Adjusting the Size and Scale of Windows Forms](adjusting-the-size-and-scale-of-windows-forms.md) diff --git a/dotnet-desktop-guide/framework/winforms/how-keyboard-input-works.md b/dotnet-desktop-guide/framework/winforms/how-keyboard-input-works.md index a8582f943d..06a573768c 100644 --- a/dotnet-desktop-guide/framework/winforms/how-keyboard-input-works.md +++ b/dotnet-desktop-guide/framework/winforms/how-keyboard-input-works.md @@ -8,12 +8,15 @@ helpviewer_keywords: ms.assetid: 9a29433c-a180-49bb-b74c-d187786584c8 --- # How Keyboard Input Works + Windows Forms processes keyboard input by raising keyboard events in response to Windows messages. Most Windows Forms applications process keyboard input exclusively by handling the keyboard events. However, you need to understand how keyboard messages work so you can implement more advanced keyboard-input scenarios, such as intercepting keys before they reach a control. This topic describes the types of key data that Windows Forms recognizes and provides an overview of how keyboard messages are routed. For information about keyboard events, see [Using Keyboard Events](using-keyboard-events.md). ## Types of Keys - Windows Forms identifies keyboard input as virtual-key codes that are represented by the bitwise enumeration. With the enumeration, you can combine a series of pressed keys to result in a single value. These values correspond to the values that accompany the WM_KEYDOWN and WM_SYSKEYDOWN Windows messages. You can detect most physical key presses by handling the or events. Character keys are a subset of the enumeration and correspond to the values that accompany the WM_CHAR and WM_SYSCHAR Windows messages. If the combination of pressed keys results in a character, you can detect the character by handling the event. Alternatively, you can use , exposed by Visual Basic programming interface, to discover which keys were pressed and send keys. For more information, see [Accessing the Keyboard](https://docs.microsoft.com/dotnet/visual-basic/developing-apps/programming/computer-resources/accessing-the-keyboar). + + Windows Forms identifies keyboard input as virtual-key codes that are represented by the bitwise enumeration. With the enumeration, you can combine a series of pressed keys to result in a single value. These values correspond to the values that accompany the WM_KEYDOWN and WM_SYSKEYDOWN Windows messages. You can detect most physical key presses by handling the or events. Character keys are a subset of the enumeration and correspond to the values that accompany the WM_CHAR and WM_SYSCHAR Windows messages. If the combination of pressed keys results in a character, you can detect the character by handling the event. Alternatively, you can use , exposed by Visual Basic programming interface, to discover which keys were pressed and send keys. For more information, see [Accessing the Keyboard](/dotnet/visual-basic/developing-apps/programming/computer-resources/accessing-the-keyboar). ## Order of Keyboard Events + As listed previously, there are 3 keyboard related events that can occur on a control. The following sequence shows the general order of the events: 1. The user pushes the "a" key, the key is preprocessed, dispatched, and a event occurs. @@ -25,6 +28,7 @@ Windows Forms processes keyboard input by raising keyboard events in response to 3. The user releases the "a" key, the key is preprocessed, dispatched and a event occurs. ## Preprocessing Keys + Like other messages, keyboard messages are processed in the method of a form or control. However, before keyboard messages are processed, the method calls one or more methods that can be overridden to handle special character keys and physical keys. You can override these methods to detect and filter certain keys before the messages are processed by the control. The following table shows the action that is being performed and the related method that occurs, in the order that the method occurs. ### Preprocessing for a KeyDown event @@ -43,6 +47,7 @@ Windows Forms processes keyboard input by raising keyboard events in response to |Check to see if the character is a mnemonic (such as &OK on a button)||This method, similar to , will be called up the control hierarchy. If the control is a container control, it checks for mnemonics by calling on itself and its child controls. If returns `true`, a event does not occur.| ## Processing Keyboard Messages + After keyboard messages reach the method of a form or control, they are processed by a set of methods that can be overridden. Each of these methods returns a value specifying whether the keyboard message has been processed and consumed by the control. If one of the methods returns `true`, then the message is considered handled, and it is not passed to the control's base or parent for further processing. Otherwise, the message stays in the message queue and may be processed in another method in the control's base or parent. The following table presents the methods that process keyboard messages. |Method|Notes| @@ -52,7 +57,8 @@ Windows Forms processes keyboard input by raising keyboard events in response to ||This method raises the , , and events, as appropriate.| ## Overriding Keyboard Methods - There are many methods available for overriding when a keyboard message is preprocessed and processed; however, some methods are much better choices than others. Following table shows tasks you might want to accomplish and the best way to override the keyboard methods. For more information on overriding methods, see [Overriding properties and methods in derived classes](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/inheritance-basics#overriding-properties-and-methods-in-derived-classes). + + There are many methods available for overriding when a keyboard message is preprocessed and processed; however, some methods are much better choices than others. Following table shows tasks you might want to accomplish and the best way to override the keyboard methods. For more information on overriding methods, see [Overriding properties and methods in derived classes](/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/inheritance-basics#overriding-properties-and-methods-in-derived-classes). |Task|Method| |----------|------------| @@ -67,6 +73,6 @@ Windows Forms processes keyboard input by raising keyboard events in response to - - - -- [My.Computer.Keyboard Object](https://docs.microsoft.com/dotnet/visual-basic/language-reference/objects/my-computer-keyboard-object) -- [Accessing the Keyboard](https://docs.microsoft.com/dotnet/visual-basic/developing-apps/programming/computer-resources/accessing-the-keyboar) +- [My.Computer.Keyboard Object](/dotnet/visual-basic/language-reference/objects/my-computer-keyboard-object) +- [Accessing the Keyboard](/dotnet/visual-basic/developing-apps/programming/computer-resources/accessing-the-keyboar) - [Using Keyboard Events](using-keyboard-events.md) diff --git a/dotnet-desktop-guide/framework/winforms/how-to-change-the-borders-of-windows-forms.md b/dotnet-desktop-guide/framework/winforms/how-to-change-the-borders-of-windows-forms.md index a72af15e15..6335c464b1 100644 --- a/dotnet-desktop-guide/framework/winforms/how-to-change-the-borders-of-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/how-to-change-the-borders-of-windows-forms.md @@ -10,11 +10,12 @@ helpviewer_keywords: ms.assetid: b3d5fa56-80c6-4b10-b505-f9672307ed55 --- # How to: Change the Borders of Windows Forms + You have several border styles to choose from when you are determining the appearance and behavior of your Windows Forms. By changing the property, you can control the resizing behavior of the form. In addition, setting the affects how the caption bar is displayed as well as what buttons might appear on it. For more information, see . There is extensive support for this task in Visual Studio. - See also [How to: Change the Borders of Windows Forms Using the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/yettzh3e(v=vs.100)). + See also [How to: Change the Borders of Windows Forms Using the Designer](/previous-versions/visualstudio/visual-studio-2010/yettzh3e(v=vs.100)). ### To set the border style of Windows Forms programmatically @@ -33,7 +34,7 @@ You have several border styles to choose from when you are determining the appea System::Windows::Forms::FormBorderStyle::FixedDialog; ``` - Also see [How to: Create Dialog Boxes at Design Time](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/55cz5x2c(v=vs.100)). + Also see [How to: Create Dialog Boxes at Design Time](/previous-versions/visualstudio/visual-studio-2010/55cz5x2c(v=vs.100)). Additionally, if you have chosen a border style for the form that provides optional **Minimize** and **Maximize** buttons, you can specify whether you want either or both of these buttons to be functional. These buttons are useful when you want to closely control the user experience. The **Minimize** and **Maximize** buttons are enabled by default, and their functionality is manipulated through the **Properties** window. diff --git a/dotnet-desktop-guide/framework/winforms/how-to-create-a-bound-control-and-format-the-displayed-data.md b/dotnet-desktop-guide/framework/winforms/how-to-create-a-bound-control-and-format-the-displayed-data.md index eee980cb52..c9c25a9107 100644 --- a/dotnet-desktop-guide/framework/winforms/how-to-create-a-bound-control-and-format-the-displayed-data.md +++ b/dotnet-desktop-guide/framework/winforms/how-to-create-a-bound-control-and-format-the-displayed-data.md @@ -13,7 +13,7 @@ With Windows Forms data binding, you can format the data displayed in a data-bou ## To bind a control and format the displayed data -1. Connect to a data source. For more information, see [Connecting to a Data Source](https://docs.microsoft.com/dotnet/framework/data/adonet/connecting-to-a-data-source). +1. Connect to a data source. For more information, see [Connecting to a Data Source](/dotnet/framework/data/adonet/connecting-to-a-data-source). 2. In Visual Studio, select the control on the form, and then open the **Properties** window. @@ -40,7 +40,7 @@ With Windows Forms data binding, you can format the data displayed in a data-bou |Currency|Specify number of decimal places by using **Decimal places** up-down control.| |Date Time|Select how the date and time should be displayed by selecting one of the items in the **Type** selection box.| |Scientific|Specify number of decimal places by using **Decimal places** up-down control.| - |Custom|Specify a custom format string using.

For more information, see [Formatting Types](https://docs.microsoft.com/dotnet/standard/base-types/formatting-types). **Note:** Custom format strings are not guaranteed to successfully round trip between the data source and bound control. Instead handle the or event for the binding and apply custom formatting in the event-handling code.| + |Custom|Specify a custom format string using.

For more information, see [Formatting Types](/dotnet/standard/base-types/formatting-types). **Note:** Custom format strings are not guaranteed to successfully round trip between the data source and bound control. Instead handle the or event for the binding and apply custom formatting in the event-handling code.| 8. Select **OK** to close the **Formatting and Advanced Binding** dialog box and return to the Properties window. diff --git a/dotnet-desktop-guide/framework/winforms/how-to-create-a-simple-bound-control-on-a-windows-form.md b/dotnet-desktop-guide/framework/winforms/how-to-create-a-simple-bound-control-on-a-windows-form.md index 2a44d142a8..f5da0e8a47 100644 --- a/dotnet-desktop-guide/framework/winforms/how-to-create-a-simple-bound-control-on-a-windows-form.md +++ b/dotnet-desktop-guide/framework/winforms/how-to-create-a-simple-bound-control-on-a-windows-form.md @@ -12,7 +12,7 @@ With *simple binding*, you can display a single data element, such as a column v ## To simple-bind a control -1. Connect to a data source. For more information, see [Connecting to a Data Source](https://docs.microsoft.com/dotnet/framework/data/adonet/connecting-to-a-data-source). +1. Connect to a data source. For more information, see [Connecting to a Data Source](/dotnet/framework/data/adonet/connecting-to-a-data-source). 2. In Visual Studio, select the control on the form and display the **Properties** window. diff --git a/dotnet-desktop-guide/framework/winforms/how-to-create-a-windows-forms-application-from-the-command-line.md b/dotnet-desktop-guide/framework/winforms/how-to-create-a-windows-forms-application-from-the-command-line.md index 2106c71ed6..5ba2f95128 100644 --- a/dotnet-desktop-guide/framework/winforms/how-to-create-a-windows-forms-application-from-the-command-line.md +++ b/dotnet-desktop-guide/framework/winforms/how-to-create-a-windows-forms-application-from-the-command-line.md @@ -14,7 +14,7 @@ ms.assetid: 45ad3f8b-1c26-4c9f-91a9-3bb0759a47a4 --- # How to: Create a Windows Forms application from the command line -The following procedures describe the basic steps that you must complete to create and run a Windows Forms application from the command line. There is extensive support for these procedures in Visual Studio. Also see [Walkthrough: Hosting a Windows Forms Control in WPF](https://docs.microsoft.com/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf). +The following procedures describe the basic steps that you must complete to create and run a Windows Forms application from the command line. There is extensive support for these procedures in Visual Studio. Also see [Walkthrough: Hosting a Windows Forms Control in WPF](/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf). ## Procedure diff --git a/dotnet-desktop-guide/framework/winforms/how-to-create-event-handlers-at-run-time-for-windows-forms.md b/dotnet-desktop-guide/framework/winforms/how-to-create-event-handlers-at-run-time-for-windows-forms.md index b46ef9e0ec..c101101f79 100644 --- a/dotnet-desktop-guide/framework/winforms/how-to-create-event-handlers-at-run-time-for-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/how-to-create-event-handlers-at-run-time-for-windows-forms.md @@ -72,4 +72,4 @@ In addition to creating events using the Windows Forms Designer in Visual Studio - [Creating Event Handlers in Windows Forms](creating-event-handlers-in-windows-forms.md) - [Event Handlers Overview](event-handlers-overview-windows-forms.md) -- [Troubleshooting Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) +- [Troubleshooting Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers) diff --git a/dotnet-desktop-guide/framework/winforms/how-to-determine-which-modifier-key-was-pressed.md b/dotnet-desktop-guide/framework/winforms/how-to-determine-which-modifier-key-was-pressed.md index 20de638fb1..93bf2684c8 100644 --- a/dotnet-desktop-guide/framework/winforms/how-to-determine-which-modifier-key-was-pressed.md +++ b/dotnet-desktop-guide/framework/winforms/how-to-determine-which-modifier-key-was-pressed.md @@ -26,6 +26,7 @@ helpviewer_keywords: ms.assetid: 1e184048-0ae3-4067-a200-d4ba31dbc2cb --- # How to: Determine Which Modifier Key Was Pressed + When you create an application that accepts the user's keystrokes, you may also want to monitor for modifier keys such as the SHIFT, ALT, and CTRL keys. When a modifier key is pressed in combination with other keys, or with mouse clicks, your application can respond appropriately. For example, if the letter S is pressed, this may simply cause an "s" to appear on the screen, but if the keys CTRL+S are pressed, the current document may be saved. If you handle the event, the property of the received by the event handler specifies which modifier keys are pressed. Alternatively, the property of specifies the character that was pressed as well as any modifier keys combined with a bitwise OR. However, if you are handling the event or a mouse event, the event handler does not receive this information. In this case, you must use the property of the class. In either case, you must perform a bitwise AND of the appropriate value and the value you are testing. The enumeration offers variations of each modifier key, so it is important that you perform the bitwise AND with the correct value. For example, the SHIFT key is represented by , , and The correct value to test SHIFT as a modifier key is . Similarly, to test for CTRL and ALT as modifiers you should use the and values, respectively. > [!NOTE] @@ -44,4 +45,4 @@ When you create an application that accepts the user's keystrokes, you may also - - - [Keyboard Input in a Windows Forms Application](keyboard-input-in-a-windows-forms-application.md) -- [How to: Determine If CapsLock is On in Visual Basic](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/9c9d1fz9(v=vs.100)) +- [How to: Determine If CapsLock is On in Visual Basic](/previous-versions/visualstudio/visual-studio-2010/9c9d1fz9(v=vs.100)) diff --git a/dotnet-desktop-guide/framework/winforms/how-to-resize-windows-forms.md b/dotnet-desktop-guide/framework/winforms/how-to-resize-windows-forms.md index 68dedd3370..810c8c0a95 100644 --- a/dotnet-desktop-guide/framework/winforms/how-to-resize-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/how-to-resize-windows-forms.md @@ -13,7 +13,7 @@ ms.assetid: 5d9dd47e-e68c-48c9-a0a3-a9ff34ba009d --- # How to: Resize Windows Forms -You can specify the size of your Windows Form in several ways. You can change both the height and the width of the form programmatically by setting a new value for the property, or adjust the or properties individually. If you're using Visual Studio, you can change the size using the Windows Forms Designer. Also see [How to: Resize Windows Forms Using the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/37k2zkwx(v=vs.100)). +You can specify the size of your Windows Form in several ways. You can change both the height and the width of the form programmatically by setting a new value for the property, or adjust the or properties individually. If you're using Visual Studio, you can change the size using the Windows Forms Designer. Also see [How to: Resize Windows Forms Using the Designer](/previous-versions/visualstudio/visual-studio-2010/37k2zkwx(v=vs.100)). ## Resize a form programmatically diff --git a/dotnet-desktop-guide/framework/winforms/more-secure-file-and-data-access-in-windows-forms.md b/dotnet-desktop-guide/framework/winforms/more-secure-file-and-data-access-in-windows-forms.md index e8a4295936..a448132e59 100644 --- a/dotnet-desktop-guide/framework/winforms/more-secure-file-and-data-access-in-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/more-secure-file-and-data-access-in-windows-forms.md @@ -15,6 +15,7 @@ helpviewer_keywords: ms.assetid: 3cd3e55b-2f5e-40dd-835d-f50f7ce08967 --- # More Secure File and Data Access in Windows Forms + The .NET Framework uses permissions to help protect resources and data. Where your application can read or write data depends on the permissions granted to the application. When your application runs in a partial trust environment, you might not have access to your data or you might have to change the way you access the data. When you encounter a security restriction, you have two options: assert the permission (assuming it has been granted to your application), or use a version of the feature written to work in partial trust. The following sections discuss how to work with file, database, and registry access from applications that are running in a partial trust environment. @@ -23,9 +24,11 @@ The .NET Framework uses permissions to help protect resources and data. Where yo > By default, tools that generate ClickOnce deployments default these deployments to requesting Full Trust from the computers on which they run. If you decide you want the added security benefits of running in partial trust, you must change this default in either Visual Studio or one of the Windows SDK tools (Mage.exe or MageUI.exe). For more information about Windows Forms security, and on how to determine the appropriate trust level for your application, see [Security in Windows Forms Overview](security-in-windows-forms-overview.md). ## File Access + The class controls file and folder access in the .NET Framework. By default, the security system does not grant the to partial trust environments such as the local intranet and Internet zones. However, an application that requires file access can still function in these environments if you modify the design of your application or use different methods to access files. By default, the local intranet zone is granted the right to have same site access and same directory access, to connect back to the site of its origin, and to read from its installation directory. By default, the Internet zone, is only granted the right to connect back to the site of its origin. ### User-Specified Files + One way to deal with not having file access permission is to prompt the user to provide specific file information by using the or class. This user interaction helps provide some assurance that the application cannot maliciously load private files or overwrite important files. The and methods provide read and write file access by opening the file stream for the file that the user specified. The methods also help protect the user's file by obscuring the file's path. > [!NOTE] @@ -130,7 +133,8 @@ private void ButtonOpen_Click(object sender, System.EventArgs e) > In Visual C#, ensure that you add code to enable the event handler. By using the code from the previous example, the following code shows how to enable the event handler.`this.ButtonOpen.Click += newSystem.Windows.Forms.EventHandler(this.ButtonOpen_Click);` ### Other Files - Sometimes you will need to read or write to files that the user does not specify, such as when you must persist application settings. In the local intranet and Internet zones, your application will not have permission to store data in a local file. However, your application will be able to store data in isolated storage. Isolated storage is an abstract data compartment (not a specific storage location) that contains one or more isolated storage files, called stores, that contain the actual directory locations where data is stored. File access permissions like are not required; instead, the class controls the permissions for isolated storage. By default, applications that are running in the local intranet and Internet zones can store data using isolated storage; however, settings like disk quota can vary. For more information about isolated storage, see [Isolated Storage](https://docs.microsoft.com/dotnet/standard/io/isolated-storage). + + Sometimes you will need to read or write to files that the user does not specify, such as when you must persist application settings. In the local intranet and Internet zones, your application will not have permission to store data in a local file. However, your application will be able to store data in isolated storage. Isolated storage is an abstract data compartment (not a specific storage location) that contains one or more isolated storage files, called stores, that contain the actual directory locations where data is stored. File access permissions like are not required; instead, the class controls the permissions for isolated storage. By default, applications that are running in the local intranet and Internet zones can store data using isolated storage; however, settings like disk quota can vary. For more information about isolated storage, see [Isolated Storage](/dotnet/standard/io/isolated-storage). The following example uses isolated storage to write data to a file located in a store. The example requires and the enumeration value. The example demonstrates reading and writing certain property values of the control to a file in isolated storage. The `Read` function would be called after the application starts and the `Write` function would be called before the application ends. The example requires that the `Read` and `Write` functions exist as members of a that contains a control named `MainButton`. @@ -343,11 +347,13 @@ public void Write() ``` ## Database Access - The permissions required to access a database vary based on the database provider; however, only applications that are running with the appropriate permissions can access a database through a data connection. For more information about the permissions that are required to access a database, see [Code Access Security and ADO.NET](https://docs.microsoft.com/dotnet/framework/data/adonet/code-access-security). + + The permissions required to access a database vary based on the database provider; however, only applications that are running with the appropriate permissions can access a database through a data connection. For more information about the permissions that are required to access a database, see [Code Access Security and ADO.NET](/dotnet/framework/data/adonet/code-access-security). - If you cannot directly access a database because you want your application to run in partial trust, you can use a Web service as an alternative means to access your data. A Web service is a piece of software that can be programmatically accessed over a network. With Web services, applications can share data across code group zones. By default, applications in the local intranet and Internet zones are granted the right to access their sites of origin, which enables them to call a Web service hosted on the same server. For more information see [Web Services in ASP.NET AJAX](https://docs.microsoft.com/previous-versions/aspnet/bb398785(v=vs.100)) or [Windows Communication Foundation](https://docs.microsoft.com/dotnet/framework/wcf/index). + If you cannot directly access a database because you want your application to run in partial trust, you can use a Web service as an alternative means to access your data. A Web service is a piece of software that can be programmatically accessed over a network. With Web services, applications can share data across code group zones. By default, applications in the local intranet and Internet zones are granted the right to access their sites of origin, which enables them to call a Web service hosted on the same server. For more information see [Web Services in ASP.NET AJAX](/previous-versions/aspnet/bb398785(v=vs.100)) or [Windows Communication Foundation](/dotnet/framework/wcf/index). ## Registry Access + The class controls access to the operating system registry. By default, only applications that are running locally can access the registry. only grants an application the right to try registry access; it does not guarantee access will succeed, because the operating system still enforces security on the registry. Because you cannot access the registry under partial trust, you may need to find other methods of storing your data. When you store application settings, use isolated storage instead of the registry. Isolated storage can also be used to store other application-specific files. You can also store global application information about the server or site of origin, because by default an application is granted the right to access the site of its origin. @@ -358,5 +364,5 @@ public void Write() - [Additional Security Considerations in Windows Forms](additional-security-considerations-in-windows-forms.md) - [Security in Windows Forms Overview](security-in-windows-forms-overview.md) - [Windows Forms Security](windows-forms-security.md) -- [Mage.exe (Manifest Generation and Editing Tool)](https://docs.microsoft.com/dotnet/framework/tools/mage-exe-manifest-generation-and-editing-tool) -- [MageUI.exe (Manifest Generation and Editing Tool, Graphical Client)](https://docs.microsoft.com/dotnet/framework/tools/mageui-exe-manifest-generation-and-editing-tool-graphical-client) +- [Mage.exe (Manifest Generation and Editing Tool)](/dotnet/framework/tools/mage-exe-manifest-generation-and-editing-tool) +- [MageUI.exe (Manifest Generation and Editing Tool, Graphical Client)](/dotnet/framework/tools/mageui-exe-manifest-generation-and-editing-tool-graphical-client) diff --git a/dotnet-desktop-guide/framework/winforms/mouse-input-in-a-windows-forms-application.md b/dotnet-desktop-guide/framework/winforms/mouse-input-in-a-windows-forms-application.md index 92d05db5f1..c41cc41901 100644 --- a/dotnet-desktop-guide/framework/winforms/mouse-input-in-a-windows-forms-application.md +++ b/dotnet-desktop-guide/framework/winforms/mouse-input-in-a-windows-forms-application.md @@ -6,9 +6,11 @@ helpviewer_keywords: ms.assetid: 743c2f3c-219e-4a52-b6b8-2657096a2da6 --- # Mouse Input in a Windows Forms Application + Windows Forms includes a variety of mouse events and additional support for customized mouse cursors, mouse capture, and drag-and-drop behavior. ## In This Section + [How Mouse Input Works in Windows Forms](how-mouse-input-works-in-windows-forms.md) Provides information about the mouse events and how to get current information and system settings for the mouse. @@ -28,5 +30,6 @@ Windows Forms includes a variety of mouse events and additional support for cust Describes how to implement drag-and-drop behavior. ## Related Sections - [Accessing the Mouse](https://docs.microsoft.com/dotnet/visual-basic/developing-apps/programming/computer-resources/accessing-the-mouse) + + [Accessing the Mouse](/dotnet/visual-basic/developing-apps/programming/computer-resources/accessing-the-mouse) Lists topics for accessing the mouse using Visual Basic. diff --git a/dotnet-desktop-guide/framework/winforms/security-in-windows-forms-overview.md b/dotnet-desktop-guide/framework/winforms/security-in-windows-forms-overview.md index 85757c19c2..c0e51c0444 100644 --- a/dotnet-desktop-guide/framework/winforms/security-in-windows-forms-overview.md +++ b/dotnet-desktop-guide/framework/winforms/security-in-windows-forms-overview.md @@ -13,20 +13,20 @@ ms.assetid: 4810dc9f-ea23-4ce1-8ea1-657f0ff1d820 Before the release of the .NET Framework, all code running on a user's computer had the same rights or permissions to access resources that a user of the computer had. For example, if the user was allowed to access the file system, the code was allowed to access the file system; if the user was allowed to access a database, the code was allowed to access that database. Although these rights or permissions may be acceptable for code in executables that the user has explicitly installed on the local computer, they may not be acceptable for potentially malicious code coming from the Internet or a local Intranet. This code should not be able to access the user's computer resources without permission. -The .NET Framework introduces an infrastructure called Code Access Security that lets you differentiate the permissions, or rights, that code has from the rights that the user has. By default, code coming from the Internet and the Intranet can only run in what is known as partial trust. Partial trust subjects an application to a series of restrictions: among other things, an application is restricted from accessing the local hard disk, and cannot run unmanaged code. The .NET Framework controls the resources that code is allowed to access based on the identity of that code: where it came from, whether it has a [Strong-Named Assemblies](https://docs.microsoft.com/dotnet/standard/assembly/strong-name), whether it is signed with a certificate, and so on. +The .NET Framework introduces an infrastructure called Code Access Security that lets you differentiate the permissions, or rights, that code has from the rights that the user has. By default, code coming from the Internet and the Intranet can only run in what is known as partial trust. Partial trust subjects an application to a series of restrictions: among other things, an application is restricted from accessing the local hard disk, and cannot run unmanaged code. The .NET Framework controls the resources that code is allowed to access based on the identity of that code: where it came from, whether it has a [Strong-Named Assemblies](/dotnet/standard/assembly/strong-name), whether it is signed with a certificate, and so on. ClickOnce technology, which you use to deploy Windows Forms applications, helps make it easier for you to develop applications that run in partial trust, in full trust, or in partial trust with elevated permissions. ClickOnce provides features such as Permission Elevation and Trusted Application Deployment so that your application can request full trust or elevated permissions from the local user in a responsible manner. ## Understanding Security in the .NET Framework -Code access security allows code to be trusted to varying degrees, depending on where the code originates and on other aspects of the code's identity. For more information about the evidence the common language runtime uses to determine security policy, see [Evidence](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/7y5x1hcd(v=vs.100)). It helps protect computer systems from malicious code and helps protect trusted code from intentionally or accidentally compromising security. Code access security also gives you more control over what actions your application can perform, because you can specify only those permissions you need your application to have. Code access security affects all managed code that targets the common language runtime, even if that code does not make a single code-access-security permission check. For more information about security in the .NET Framework, see [Key Security Concepts](https://docs.microsoft.com/dotnet/standard/security/key-security-concepts) and [Code Access Security Basics](https://docs.microsoft.com/dotnet/framework/misc/code-access-security-basics). +Code access security allows code to be trusted to varying degrees, depending on where the code originates and on other aspects of the code's identity. For more information about the evidence the common language runtime uses to determine security policy, see [Evidence](/previous-versions/dotnet/netframework-4.0/7y5x1hcd(v=vs.100)). It helps protect computer systems from malicious code and helps protect trusted code from intentionally or accidentally compromising security. Code access security also gives you more control over what actions your application can perform, because you can specify only those permissions you need your application to have. Code access security affects all managed code that targets the common language runtime, even if that code does not make a single code-access-security permission check. For more information about security in the .NET Framework, see [Key Security Concepts](/dotnet/standard/security/key-security-concepts) and [Code Access Security Basics](/dotnet/framework/misc/code-access-security-basics). If the user run a Windows Forms executable file directly off of a Web server or a file share, the degree of trust granted to your application depends on where the code resides, and how it is started. When an application runs, it is automatically evaluated and it receives a named permission set from the common language runtime. By default, the code from the local computer is granted the Full Trust permission set, code from a local network is granted the Local Intranet permission set, and code from the Internet is granted the Internet permission set. > [!NOTE] > In the .NET Framework version 1.0 Service Pack 1 and Service Pack 2, the Internet zone code group receives the Nothing permission set. In all other releases of the .NET Framework, the Internet zone code group receives the Internet permissions set. > -> The default permissions granted in each of these permission sets are listed in the [Default Security Policy](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/03kwzyfc(v=vs.100)) topic. Depending on the permissions that the application receives, it either runs correctly or generates a security exception. +> The default permissions granted in each of these permission sets are listed in the [Default Security Policy](/previous-versions/dotnet/netframework-4.0/03kwzyfc(v=vs.100)) topic. Depending on the permissions that the application receives, it either runs correctly or generates a security exception. > > Many Windows Forms applications will be deployed using ClickOnce. The tools used for generating a ClickOnce deployment have different security defaults than what was discussed earlier. For more information, see the following discussion. @@ -34,7 +34,7 @@ The actual permissions granted to your application can be different from the def ## Developing a More Secure Windows Forms Application -Security is important in all steps of application development. Start by reviewing and following the [Secure Coding Guidelines](https://docs.microsoft.com/dotnet/standard/security/secure-coding-guidelines). +Security is important in all steps of application development. Start by reviewing and following the [Secure Coding Guidelines](/dotnet/standard/security/secure-coding-guidelines). Next, decide whether your application must run in full trust, or whether it should run in partial trust. Running your application in full trust makes it easier to access resources on the local computer, but exposes your application and its users to high security risks if you do not design and develop your application strictly according to the Secure Coding Guidelines topic. Running your application in partial trust makes it easier to develop a more secure application and reduces much risk, but requires more planning in how to implement certain features. @@ -42,7 +42,7 @@ If you choose partial trust (that is, either the Internet or Local Intranet perm If your application needs more permissions than partial trust allows, but you do not want to run in full trust, you can run in partial trust while asserting only those additional permissions you need. For example, if you want to run in partial trust, but must grant your application read-only access to a directory on the user's file system, you can request only for that directory. Used correctly, this approach can give your application increased functionality and minimize security risks to your users. -When you develop an application that will run in partial trust, keep track of what permissions your application must run and what permissions your application could optionally use. When all the permissions are known, you should make a declarative request for permission at the application level. Requesting permissions informs the .NET Framework run time about which permissions your application needs and which permissions it specifically does not want. For more information about requesting permissions, see [Requesting Permissions](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/yd267cce(v=vs.100)). +When you develop an application that will run in partial trust, keep track of what permissions your application must run and what permissions your application could optionally use. When all the permissions are known, you should make a declarative request for permission at the application level. Requesting permissions informs the .NET Framework run time about which permissions your application needs and which permissions it specifically does not want. For more information about requesting permissions, see [Requesting Permissions](/previous-versions/dotnet/netframework-4.0/yd267cce(v=vs.100)). When you request optional permissions, you must handle security exceptions that will be generated if your application performs an action that requires permissions not granted to it. Appropriate handling of the will ensure that your application can continue to operate. Your application can use the exception to determine whether a feature should become disabled for the user. For example, an application can disable the **Save** menu option if the required file permission is not granted. @@ -71,7 +71,7 @@ The following table describes these technologies. Which technology you choose will depend on your deployment environment. For more information, see [Choosing a ClickOnce Deployment Strategy](/visualstudio/deployment/choosing-a-clickonce-deployment-strategy). -By default, ClickOnce applications deployed using either Visual Studio or the .NET Framework SDK tools (Mage.exe and MageUI.exe) are configured to run on a client computer that has Full Trust. If you are deploying your application by using partial trust or by using only some additional permissions, you will have to change this default. You can do this with either Visual Studio or the .NET Framework SDK tool MageUI.exe when you configure your deployment. For more information about how to use MageUI.exe, see [Walkthrough: Manually deploying a ClickOnce application](/visualstudio/deployment/walkthrough-manually-deploying-a-clickonce-application). Also see [How to: Set Custom Permissions for a ClickOnce Application](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2012/hafybdaa(v=vs.110)) or [How to: Set Custom Permissions for a ClickOnce Application](/visualstudio/deployment/how-to-set-custom-permissions-for-a-clickonce-application). +By default, ClickOnce applications deployed using either Visual Studio or the .NET Framework SDK tools (Mage.exe and MageUI.exe) are configured to run on a client computer that has Full Trust. If you are deploying your application by using partial trust or by using only some additional permissions, you will have to change this default. You can do this with either Visual Studio or the .NET Framework SDK tool MageUI.exe when you configure your deployment. For more information about how to use MageUI.exe, see [Walkthrough: Manually deploying a ClickOnce application](/visualstudio/deployment/walkthrough-manually-deploying-a-clickonce-application). Also see [How to: Set Custom Permissions for a ClickOnce Application](/previous-versions/visualstudio/visual-studio-2012/hafybdaa(v=vs.110)) or [How to: Set Custom Permissions for a ClickOnce Application](/visualstudio/deployment/how-to-set-custom-permissions-for-a-clickonce-application). For more information about the security aspects of ClickOnce and Permission Elevation, see [Securing ClickOnce Applications](/visualstudio/deployment/securing-clickonce-applications). For more information about Trusted Application Deployment, see [Trusted Application Deployment Overview](/visualstudio/deployment/trusted-application-deployment-overview). @@ -82,8 +82,8 @@ If you have deployed your Windows Forms application by using Visual Studio, you ## See also - [Windows Forms Security](windows-forms-security.md) -- [Code Access Security Basics](https://docs.microsoft.com/dotnet/framework/misc/code-access-security-basics) +- [Code Access Security Basics](/dotnet/framework/misc/code-access-security-basics) - [ClickOnce Security and Deployment](/visualstudio/deployment/clickonce-security-and-deployment) - [Trusted Application Deployment Overview](/visualstudio/deployment/trusted-application-deployment-overview) -- [Mage.exe (Manifest Generation and Editing Tool)](https://docs.microsoft.com/dotnet/framework/tools/mage-exe-manifest-generation-and-editing-tool) -- [MageUI.exe (Manifest Generation and Editing Tool, Graphical Client)](https://docs.microsoft.com/dotnet/framework/tools/mageui-exe-manifest-generation-and-editing-tool-graphical-client) +- [Mage.exe (Manifest Generation and Editing Tool)](/dotnet/framework/tools/mage-exe-manifest-generation-and-editing-tool) +- [MageUI.exe (Manifest Generation and Editing Tool, Graphical Client)](/dotnet/framework/tools/mageui-exe-manifest-generation-and-editing-tool-graphical-client) diff --git a/dotnet-desktop-guide/framework/winforms/user-input-validation-in-windows-forms.md b/dotnet-desktop-guide/framework/winforms/user-input-validation-in-windows-forms.md index ec5a92a2d7..7443fedf5d 100644 --- a/dotnet-desktop-guide/framework/winforms/user-input-validation-in-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/user-input-validation-in-windows-forms.md @@ -10,9 +10,11 @@ helpviewer_keywords: ms.assetid: 4ec07681-1dee-4bf9-be5e-718f635a33a1 --- # User Input Validation in Windows Forms + When users enter data into your application, you may want to verify that the data is valid before your application uses it. You may require that certain text fields not be zero-length, that a field be formatted as a telephone number or other type of well-formed data, or that a string not contain any unsafe characters that could be used to compromise the security of a database. Windows Forms provides several ways for you to validate input in your application. ## Validation with the MaskedTextBox Control + If you need to require users to enter data in a well-defined format, such as a telephone number or a part number, you can accomplish this quickly and with minimal code by using the control. A *mask* is a string made up of characters from a masking language that specifies which characters can be entered at any given position in the text box. The control displays a set of prompts to the user. If the user types an incorrect entry, for example, the user types a letter when a digit is required, the control will automatically reject the input. The masking language that is used by is very flexible. It allows you to specify required characters, optional characters, literal characters, such as hyphens and parentheses, currency characters, and date separators. The control also works well when bound to a data source. The event on a data binding can be used to reformat incoming data to comply with the mask, and the event can be used to reformat outgoing data to comply with the specifications of the data field. @@ -20,11 +22,12 @@ When users enter data into your application, you may want to verify that the dat For more information, see [MaskedTextBox Control](./controls/maskedtextbox-control-windows-forms.md). ## Event-Driven Validation + If you want full programmatic control over validation, or need to perform complex validation checks, you should use the validation events built into most Windows Forms controls. Each control that accepts free-form user input has a event that will occur whenever the control requires data validation. In the event-handling method, you can validate user input in several ways. For example, if you have a text box that must contain a postal code, you can perform the validation in the following ways: - If the postal code must belong to a specific group of zip codes, you can perform a string comparison on the input to validate the data entered by the user. For example, if the postal code must be in the set {10001, 10002, 10003}, then you can use a string comparison to validate the data. -- If the postal code must be in a specific form you can use regular expressions to validate the data entered by the user. For example, to validate the form `#####` or `#####-####`, you can use the regular expression `^(\d{5})(-\d{4})?$`. To validate the form `A#A #A#`, you can use the regular expression `[A-Z]\d[A-Z] \d[A-Z]\d`. For more information about regular expressions, see [.NET Framework Regular Expressions](https://docs.microsoft.com/dotnet/standard/base-types/regular-expressions) and [Regular Expression Examples](https://docs.microsoft.com/dotnet/standard/base-types/regular-expression-example-scanning-for-hrefs). +- If the postal code must be in a specific form you can use regular expressions to validate the data entered by the user. For example, to validate the form `#####` or `#####-####`, you can use the regular expression `^(\d{5})(-\d{4})?$`. To validate the form `A#A #A#`, you can use the regular expression `[A-Z]\d[A-Z] \d[A-Z]\d`. For more information about regular expressions, see [.NET Framework Regular Expressions](/dotnet/standard/base-types/regular-expressions) and [Regular Expression Examples](/dotnet/standard/base-types/regular-expression-example-scanning-for-hrefs). - If the postal code must be a valid United States Zip code, you could call a Zip code Web service to validate the data entered by the user. @@ -33,6 +36,7 @@ When users enter data into your application, you may want to verify that the dat For a code example that validates an email address in a , see . ### Data Binding and Event-Driven Validation + Validation is very useful when you have bound your controls to a data source, such as a database table. By using validation, you can make sure that your control's data satisfies the format required by the data source, and that it does not contain any special characters such as quotation marks and back slashes that might be unsafe. When you use data binding, the data in your control is synchronized with the data source during execution of the event. If you cancel the event, the data will not be synchronized with the data source. @@ -41,9 +45,11 @@ When users enter data into your application, you may want to verify that the dat > If you have custom validation that takes place after the event, it will not affect the data binding. For example, if you have code in a event that attempts to cancel the data binding, the data binding will still occur. In this case, to perform validation in the event, change the control's **Data Source Update Mode** property (**under (Databindings)**\\**(Advanced)**) from **OnValidation** to **Never**, and add *Control*`.DataBindings["`*\*`"].WriteValue()` to your validation code. ### Implicit and Explicit Validation + So when does a control's data get validated? This is up to you, the developer. You can use either implicit or explicit validation, depending on the needs of your application. #### Implicit Validation + The implicit validation approach validates data as the user enters it. You can validate the data as the data is entered in a control by reading the keys as they are pressed, or more commonly whenever the user takes the input focus away from one control and moves to the next. This approach is useful when you want to give the user immediate feedback about the data as they are working. If you want to use implicit validation for a control, you must set that control's property to or . If you cancel the event, the behavior of the control will be determined by what value that you assigned to . If you assigned , canceling the event will cause the event not to occur. Input focus will remain on the current control until the user changes the data to a valid input. If you assigned , the event will not occur when you cancel the event, but focus will still change to the next control. @@ -51,6 +57,7 @@ When users enter data into your application, you may want to verify that the dat Assigning to the property prevents implicit validation altogether. To validate your controls, you will have to use explicit validation. #### Explicit Validation + The explicit validation approach validates data at one time. You can validate the data in response to a user action, such as clicking a Save button or a Next link. When the user action occurs, you can trigger explicit validation in one of the following ways: - Call to validate the last control to have lost focus. @@ -60,6 +67,7 @@ When users enter data into your application, you may want to verify that the dat - Call a custom method to validate the data in the controls manually. #### Default Implicit Validation Behavior for Windows Forms Controls + Different Windows Forms controls have different defaults for their property. The following table shows the most common controls and their defaults. |Control|Default Validation Behavior| @@ -72,6 +80,7 @@ When users enter data into your application, you may want to verify that the dat ||| ## Closing the Form and Overriding Validation + When a control maintains focus because the data it contains is invalid, it is impossible to close the parent form in one of the usual ways: - By clicking the **Close** button. @@ -91,4 +100,4 @@ When users enter data into your application, you may want to verify that the dat - - - [MaskedTextBox Control](./controls/maskedtextbox-control-windows-forms.md) -- [Regular Expression Examples](https://docs.microsoft.com/dotnet/standard/base-types/regular-expression-example-scanning-for-hrefs) +- [Regular Expression Examples](/dotnet/standard/base-types/regular-expression-example-scanning-for-hrefs) diff --git a/dotnet-desktop-guide/framework/winforms/windows-forms-accessibility-improvements.md b/dotnet-desktop-guide/framework/winforms/windows-forms-accessibility-improvements.md index 559c0168e2..8d95d17e1b 100644 --- a/dotnet-desktop-guide/framework/winforms/windows-forms-accessibility-improvements.md +++ b/dotnet-desktop-guide/framework/winforms/windows-forms-accessibility-improvements.md @@ -91,8 +91,8 @@ The following changes apply to the con ## UI automation support for DataGridView, PropertyGrid, ListBox, ComboBox, ToolStrip, and other controls -UI Automation support is enabled for controls at runtime but isn't used during design time. For an overview of UI automation, see the [UI Automation Overview](https://docs.microsoft.com/dotnet/framework/ui-automation/ui-automation-overview). +UI Automation support is enabled for controls at runtime but isn't used during design time. For an overview of UI automation, see the [UI Automation Overview](/dotnet/framework/ui-automation/ui-automation-overview). ## See also -- [Accessibility Best Practices](https://docs.microsoft.com/dotnet/framework/ui-automation/accessibility-best-practices). +- [Accessibility Best Practices](/dotnet/framework/ui-automation/accessibility-best-practices). diff --git a/dotnet-desktop-guide/framework/winforms/windows-forms-security.md b/dotnet-desktop-guide/framework/winforms/windows-forms-security.md index 81e819dedf..01ae8c00cb 100644 --- a/dotnet-desktop-guide/framework/winforms/windows-forms-security.md +++ b/dotnet-desktop-guide/framework/winforms/windows-forms-security.md @@ -11,9 +11,11 @@ helpviewer_keywords: ms.assetid: 932d438a-5285-46d8-a958-8c93d0ad6cae --- # Windows Forms Security + Windows Forms features a security model that is code-based (security levels are set for code, regardless of the user running the code). This is in addition to any security schemas that may be in place already on your computer system. These can include those in the browser (such as the zone-based security available in Internet Explorer) or the operating system (such as the credential-based security of Windows NT). ## In This Section + [Security in Windows Forms Overview](security-in-windows-forms-overview.md) Briefly explains the .NET Framework security model and the basic steps necessary to ensure the Windows Forms in your application are secure. @@ -27,29 +29,30 @@ Windows Forms features a security model that is code-based (security levels are Describes performing window manipulation, using the Clipboard, and making calls to unmanaged code in a semi-trusted environment. ## Related Sections - [Default Security Policy](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/03kwzyfc(v=vs.100)) + + [Default Security Policy](/previous-versions/dotnet/netframework-4.0/03kwzyfc(v=vs.100)) Lists the default permissions granted in the Full Trust, Local Intranet, and Internet permission sets. - [General Security Policy Administration](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ed5htz45(v=vs.100)) + [General Security Policy Administration](/previous-versions/dotnet/netframework-4.0/ed5htz45(v=vs.100)) Gives information about the administering the .NET Framework security policy and elevating permissions. - [Dangerous Permissions and Policy Administration](https://docs.microsoft.com/dotnet/framework/misc/dangerous-permissions-and-policy-administration) + [Dangerous Permissions and Policy Administration](/dotnet/framework/misc/dangerous-permissions-and-policy-administration) Discusses some of the.NET Framework permissions that can potentially allow the security system to be circumvented. - [Secure Coding Guidelines](https://docs.microsoft.com/dotnet/standard/security/secure-coding-guidelines) + [Secure Coding Guidelines](/dotnet/standard/security/secure-coding-guidelines) Links to topics that explain the best practices for securely writing code against the .NET Framework. - [Requesting Permissions](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/yd267cce(v=vs.100)) + [Requesting Permissions](/previous-versions/dotnet/netframework-4.0/yd267cce(v=vs.100)) Discusses the use of attributes to let the runtime know what permissions your code needs to run. - [Key Security Concepts](https://docs.microsoft.com/dotnet/standard/security/key-security-concepts) + [Key Security Concepts](/dotnet/standard/security/key-security-concepts) Links to topics that cover the basic aspects of code security. - [Code Access Security Basics](https://docs.microsoft.com/dotnet/framework/misc/code-access-security-basics) + [Code Access Security Basics](/dotnet/framework/misc/code-access-security-basics) Discusses the basics of working with the .NET Framework run time security policy. - [Determining When to Modify Security Policy](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/xky659fc(v=vs.100)) + [Determining When to Modify Security Policy](/previous-versions/dotnet/netframework-4.0/xky659fc(v=vs.100)) Explains how to determine when your applications need to diverge from the default security policy. - [Deploying Security Policy](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/13wcxx6y(v=vs.100)) + [Deploying Security Policy](/previous-versions/dotnet/netframework-4.0/13wcxx6y(v=vs.100)) Discusses the best manner for deploying security policy changes. From c1d6e1d23e4726dd3b4751270512248617dd6a30 Mon Sep 17 00:00:00 2001 From: David Coulter Date: Thu, 5 Nov 2020 12:01:28 -0800 Subject: [PATCH 2/5] Links: .NET Desktop - net (#107) * Links: .NET Desktop - net * Update dotnet-desktop-guide/net/wpf/index.yml * Update dotnet-desktop-guide/net/wpf/toc.yml Co-authored-by: Andy De George <67293991+adegeo@users.noreply.github.com> --- dotnet-desktop-guide/net/winforms/input-keyboard/overview.md | 2 +- dotnet-desktop-guide/net/wpf/index.yml | 2 +- .../net/wpf/migration/convert-project-from-net-framework.md | 4 ++-- dotnet-desktop-guide/net/wpf/overview/index.md | 2 +- dotnet-desktop-guide/net/wpf/toc.yml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dotnet-desktop-guide/net/winforms/input-keyboard/overview.md b/dotnet-desktop-guide/net/winforms/input-keyboard/overview.md index d2ec35b488..75d8ae7c49 100644 --- a/dotnet-desktop-guide/net/winforms/input-keyboard/overview.md +++ b/dotnet-desktop-guide/net/winforms/input-keyboard/overview.md @@ -13,7 +13,7 @@ helpviewer_keywords: # Overview of using the keyboard (Windows Forms .NET) -In Windows Forms, user input is sent to applications in the form of [Windows messages](https://docs.microsoft.com/windows/win32/winmsg/about-messages-and-message-queues). A series of overridable methods process these messages at the application, form, and control level. When these methods receive keyboard messages, they raise events that can be handled to get information about the keyboard input. In many cases, Windows Forms applications will be able to process all user input simply by handling these events. In other cases, an application may need to override one of the methods that process messages in order to intercept a particular message before it is received by the application, form, or control. +In Windows Forms, user input is sent to applications in the form of [Windows messages](/windows/win32/winmsg/about-messages-and-message-queues). A series of overridable methods process these messages at the application, form, and control level. When these methods receive keyboard messages, they raise events that can be handled to get information about the keyboard input. In many cases, Windows Forms applications will be able to process all user input simply by handling these events. In other cases, an application may need to override one of the methods that process messages in order to intercept a particular message before it is received by the application, form, or control. [!INCLUDE [desktop guide under construction](../../includes/desktop-guide-preview-note.md)] diff --git a/dotnet-desktop-guide/net/wpf/index.yml b/dotnet-desktop-guide/net/wpf/index.yml index c960e26823..b2ca872981 100644 --- a/dotnet-desktop-guide/net/wpf/index.yml +++ b/dotnet-desktop-guide/net/wpf/index.yml @@ -35,7 +35,7 @@ landingContent: - linkListType: tutorial links: - text: Create a WPF application - url: https://docs.microsoft.com/visualstudio/get-started/csharp/tutorial-wpf?toc=/dotnet/desktop-wpf/toc.json&bc=/dotnet/breadcrumb/toc.json + url: /visualstudio/get-started/csharp/tutorial-wpf?bc=%252fdotnet%252fbreadcrumb%252ftoc.json&toc=%252fdotnet%252fdesktop-wpf%252ftoc.json # Card - title: Fundamentals - XAML diff --git a/dotnet-desktop-guide/net/wpf/migration/convert-project-from-net-framework.md b/dotnet-desktop-guide/net/wpf/migration/convert-project-from-net-framework.md index 866874f3e2..bbd3af5772 100644 --- a/dotnet-desktop-guide/net/wpf/migration/convert-project-from-net-framework.md +++ b/dotnet-desktop-guide/net/wpf/migration/convert-project-from-net-framework.md @@ -213,10 +213,10 @@ If you have many source files that would need to be excluded this way, you can d ### A brief aside on multi-pass compilers -After removing the offending file from the Bean Trader sample, you can re-build and will get four errors. Didn't you have one before? Why did the number of errors go up? The C# compiler is a [multi-pass compiler](https://docs.microsoft.com/archive/blogs/ericlippert/how-many-passes). This means that it goes through each source file twice. First, the compiler just looks at metadata and declarations in each source file and identifies any declaration-level problems. Those are the errors you've fixed. Then it goes through the code again to build the C# source into IL; those are the second set of errors that you're seeing now. +After removing the offending file from the Bean Trader sample, you can re-build and will get four errors. Didn't you have one before? Why did the number of errors go up? The C# compiler is a [multi-pass compiler](/archive/blogs/ericlippert/how-many-passes). This means that it goes through each source file twice. First, the compiler just looks at metadata and declarations in each source file and identifies any declaration-level problems. Those are the errors you've fixed. Then it goes through the code again to build the C# source into IL; those are the second set of errors that you're seeing now. > [!NOTE] -> The C# compiler does [more than just two passes](https://docs.microsoft.com/archive/blogs/ericlippert/how-many-passes), but the end result is that compiler errors for large code changes like this tend to come in two waves. +> The C# compiler does [more than just two passes](/archive/blogs/ericlippert/how-many-passes), but the end result is that compiler errors for large code changes like this tend to come in two waves. ### Third-party dependency fixes (Castle.Windsor) diff --git a/dotnet-desktop-guide/net/wpf/overview/index.md b/dotnet-desktop-guide/net/wpf/overview/index.md index 4c7c890560..63547b6291 100644 --- a/dotnet-desktop-guide/net/wpf/overview/index.md +++ b/dotnet-desktop-guide/net/wpf/overview/index.md @@ -140,6 +140,6 @@ Every framework-level element ( or Date: Thu, 5 Nov 2020 13:50:29 -0800 Subject: [PATCH 3/5] Links: .NET Desktop - framework\wpf (#109) * Links: .NET Desktop - framework\wpf * Apply suggestions from code review Co-authored-by: Andy De George <67293991+adegeo@users.noreply.github.com> --- .../alignment-margins-and-padding-overview.md | 19 +++++++- .../wpf/advanced/annotations-overview.md | 11 ++++- .../wpf/advanced/commanding-overview.md | 25 +++++++++- .../advanced/creating-an-ink-input-control.md | 13 +++++- .../framework/wpf/advanced/documents.md | 4 +- .../wpf/advanced/drawing-formatted-text.md | 13 +++++- .../wpf/advanced/graphics-rendering-tiers.md | 17 +++++-- .../wpf/advanced/handwriting-recognition.md | 6 ++- .../how-to-analyze-ink-with-analysis-hints.md | 6 ++- ...e-visual-styles-in-a-hybrid-application.md | 4 +- ...how-to-programmatically-print-xps-files.md | 10 ++-- .../how-to-use-a-thicknessconverter-object.md | 6 ++- .../intercepting-input-from-the-stylus.md | 13 +++++- .../advanced/mc-processcontent-attribute.md | 4 +- .../wpf/advanced/opentype-font-features.md | 33 ++++++++++++- .../optimizing-performance-object-behavior.md | 17 ++++++- .../packaging-fonts-with-applications.md | 19 +++++++- ...-model-windows-forms-and-com-versus-wpf.md | 31 +++++++------ .../framework/wpf/advanced/trees-in-wpf.md | 25 +++++++++- .../troubleshooting-hybrid-applications.md | 37 ++++++++++++++- .../wpf/advanced/typography-in-wpf.md | 18 +++++++- ...-binding-to-data-in-hybrid-applications.md | 2 +- ...-wpf-composite-control-in-windows-forms.md | 5 +- ...-windows-forms-composite-control-in-wpf.md | 16 ++++++- ...through-localizing-a-hybrid-application.md | 4 +- ...roperties-using-the-elementhost-control.md | 4 +- ...ties-using-the-windowsformshost-element.md | 2 - ...ms-controls-and-equivalent-wpf-controls.md | 3 +- ...aces-and-namespace-mapping-for-wpf-xaml.md | 16 ++++++- .../application-management-overview.md | 4 +- .../build-and-deploy-how-to-topics.md | 4 +- .../deploying-a-wpf-application-wpf.md | 20 +++++++- ...dd-a-splash-screen-to-a-wpf-application.md | 2 +- .../how-to-create-an-add-in-that-is-a-ui.md | 13 +++++- ...w-to-create-an-add-in-that-returns-a-ui.md | 20 +++++++- ...ther-the-net-framework-3-0-is-installed.md | 5 +- ...n-application-scope-resource-dictionary.md | 4 +- .../wpf/app-development/iwpfhostsupport.md | 4 +- ...native-wpf-browser-hosting-support-apis.md | 5 +- .../app-development/wpf-add-ins-overview.md | 16 +++---- .../wpf-xaml-browser-applications-overview.md | 19 +++++++- ...hat-has-an-access-key-and-text-wrapping.md | 4 +- .../wpf/controls/how-to-crop-an-image.md | 6 ++- .../how-to-customize-the-ticks-on-a-slider.md | 4 +- .../how-to-define-a-groupbox-template.md | 4 +- .../framework/wpf/controls/label.md | 5 +- .../wpf/controls/listbox-how-to-topics.md | 5 +- .../framework/wpf/controls/panels-overview.md | 46 +++++++++++++++++-- .../wpf/controls/scrollviewer-overview.md | 14 +++++- .../wpf/controls/tooltip-overview.md | 15 +++++- ...l-server-database-in-a-datagrid-control.md | 4 +- .../data/how-to-create-a-binding-in-code.md | 4 +- .../data/how-to-implement-prioritybinding.md | 4 +- ...-data-binding-with-linq-to-xml-overview.md | 2 +- ...hrough-my-first-wpf-desktop-application.md | 2 +- .../wpf/getting-started/wpf-walkthroughs.md | 13 +++--- .../animation-tips-and-tricks.md | 14 +++++- .../bitmap-effects-overview.md | 12 +++-- .../drawing-objects-overview.md | 34 +++++++++++--- ...-frame-interval-using-compositiontarget.md | 4 +- .../graphics-multimedia/imaging-overview.md | 19 +++++++- .../wpf/graphics-multimedia/index.md | 2 +- .../property-animation-techniques-overview.md | 12 ++++- .../storyboards-overview.md | 6 +-- .../framework/wpf/security-wpf.md | 31 ++++++++++--- ...wpf-security-strategy-platform-security.md | 16 ++++++- ...-security-strategy-security-engineering.md | 12 ++++- 67 files changed, 657 insertions(+), 136 deletions(-) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/alignment-margins-and-padding-overview.md b/dotnet-desktop-guide/framework/wpf/advanced/alignment-margins-and-padding-overview.md index 82df744d3c..60b60f19b7 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/alignment-margins-and-padding-overview.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/alignment-margins-and-padding-overview.md @@ -13,10 +13,13 @@ helpviewer_keywords: ms.assetid: 9c6a2009-9b86-4e40-8605-0a2664dc3973 --- # Alignment, Margins, and Padding Overview + The class exposes several properties that are used to precisely position child elements. This topic discusses four of the most important properties: , , , and . The effects of these properties are important to understand, because they provide the basis for controlling the position of elements in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] applications. + ## Introduction to Element Positioning + There are numerous ways to position elements using [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]. However, achieving ideal layout goes beyond simply choosing the right element. Fine control of positioning requires an understanding of the , , , and properties. The following illustration shows a layout scenario that utilizes several positioning properties. @@ -35,14 +38,18 @@ The class exposes several properties that ![Positioning Properties with Screen Call-outs](./media/layout-margins-padding-alignment-graphic2.PNG "layout_margins_padding_alignment_graphic2") + ## Understanding Alignment Properties + The and properties describe how a child element should be positioned within a parent element's allocated layout space. By using these properties together, you can position child elements precisely. For example, child elements of a can specify four different horizontal alignments: , , or , or to to fill available space. Similar values are available for vertical positioning. > [!NOTE] > Explicitly-set and properties on an element take precedence over the property value. Attempting to set , , and a value of `Stretch` results in the `Stretch` request being ignored. + ### HorizontalAlignment Property + The property declares the horizontal alignment characteristics to apply to child elements. The following table shows each of the possible values of the property. |Member|Description| @@ -62,7 +69,9 @@ The class exposes several properties that ![HorizontalAlignment Sample](./media/layout-horizontal-alignment-graphic.PNG "layout_horizontal_alignment_graphic") + ### VerticalAlignment Property + The property describes the vertical alignment characteristics to apply to child elements. The following table shows each of the possible values for the property. |Member|Description| @@ -83,7 +92,9 @@ The class exposes several properties that ![VerticalAlignment property sample](./media/layout-vertical-alignment-graphic.PNG "layout_vertical_alignment_graphic") + ## Understanding Margin Properties + The property describes the distance between an element and its child or peers. values can be uniform, by using syntax like `Margin="20"`. With this syntax, a uniform of 20 device independent pixels would be applied to the element. values can also take the form of four distinct values, each value describing a distinct margin to apply to the left, top, right, and bottom (in that order), like `Margin="0,10,5,25"`. Proper use of the property enables very fine control of an element's rendering position and the rendering position of its neighbor elements and children. > [!NOTE] @@ -104,7 +115,9 @@ The class exposes several properties that [!code-xaml[MarginPaddingAlignmentSample#2](~/samples/snippets/xaml/VS_Snippets_Wpf/MarginPaddingAlignmentSample/XAML/default.xaml#2)] + ## Understanding the Padding Property + Padding is similar to in most respects. The Padding property is exposed on only on a few classes, primarily as a convenience: , , , and are samples of classes that expose a Padding property. The property enlarges the effective size of a child element by the specified value. The following example shows how to apply to a parent element. @@ -115,7 +128,9 @@ The class exposes several properties that [!code-xaml[MarginPaddingAlignmentSample#3](~/samples/snippets/xaml/VS_Snippets_Wpf/MarginPaddingAlignmentSample/XAML/default.xaml#3)] + ## Using Alignment, Margins, and Padding in an Application + , , , and provide the positioning control necessary to create a complex [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)]. You can use the effects of each property to change child-element positioning, enabling flexibility in creating dynamic applications and user experiences. The following example demonstrates each of the concepts that are detailed in this topic. Building on the infrastructure found in the first sample in this topic, this example adds a element as a child of the in the first sample. is applied to the parent element. The is used to partition space between three child elements. elements are again used to show the various effects of and . elements are added to each to better define the various properties applied to the elements in each column. @@ -130,7 +145,9 @@ The class exposes several properties that ![Several positioning properties in one application](./media/layout-margins-padding-aligment-graphic3.PNG "layout_margins_padding_aligment_graphic3") + ## What's Next + Positioning properties defined by the class enable fine control of element placement within [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications. You now have several techniques you can use to better position elements using [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]. Additional resources are available that explain [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] layout in greater detail. The [Panels Overview](../controls/panels-overview.md) topic contains more detail about the various elements. The topic [Walkthrough: My first WPF desktop application](../getting-started/walkthrough-my-first-wpf-desktop-application.md) introduces advanced techniques that use layout elements to position components and bind their actions to data sources. @@ -143,4 +160,4 @@ The class exposes several properties that - - [Panels Overview](../controls/panels-overview.md) - [Layout](layout.md) -- [WPF Layout Gallery Sample](https://go.microsoft.com/fwlink/?LinkID=160054) +- [WPF Layout Gallery Sample](https://github.com/microsoft/WPF-Samples/tree/master/Getting%20Started/ControlsAndLayout) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/annotations-overview.md b/dotnet-desktop-guide/framework/wpf/advanced/annotations-overview.md index 7b4754326b..bfb2c55546 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/annotations-overview.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/annotations-overview.md @@ -11,12 +11,15 @@ helpviewer_keywords: ms.assetid: 716bf474-29bd-4c74-84a4-8e0744bdad62 --- # Annotations Overview + Writing notes or comments on paper documents is such a commonplace activity that we almost take it for granted. These notes or comments are "annotations" that we add to a document to flag information or to highlight items of interest for later reference. Although writing notes on printed documents is easy and commonplace, the ability to add personal comments to electronic documents is typically very limited, if available at all. This topic reviews several common types of annotations, specifically sticky notes and highlights, and illustrates how the Microsoft Annotations Framework facilitates these types of annotations in applications through the Windows Presentation Foundation (WPF) document viewing controls. WPF document viewing controls that support annotations include and , as well as controls derived from such as and . + ## Sticky Notes + A typical sticky note contains information written on a small piece of colored paper that is then "stuck" to a document. Digital sticky notes provide similar functionality for electronic documents, but with the added flexibility to include many other types of content such as typed text, handwritten notes (for example, Tablet PC "ink" strokes), or Web links. The following illustration shows some examples of highlight, text sticky note, and ink sticky note annotations. @@ -29,7 +32,9 @@ Writing notes or comments on paper documents is such a commonplace activity that [!code-vb[DocViewerAnnotationsXml#DocViewXmlStartAnnotations](~/samples/snippets/visualbasic/VS_Snippets_Wpf/DocViewerAnnotationsXml/visualbasic/window1.xaml.vb#docviewxmlstartannotations)] + ## Highlights + People use creative methods to draw attention to items of interest when they mark up a paper document, such as underlining, highlighting, circling words in a sentence, or drawing marks or notations in the margin. Highlight annotations in Microsoft Annotations Framework provide a similar feature for marking up information displayed in WPF document viewing controls. The following illustration shows an example of a highlight annotation. @@ -41,13 +46,17 @@ Writing notes or comments on paper documents is such a commonplace activity that [!code-xaml[DocViewerAnnotationsXps#CreateDeleteAnnotations](~/samples/snippets/csharp/VS_Snippets_Wpf/DocViewerAnnotationsXps/CSharp/Window1.xaml#createdeleteannotations)] + ## Data Anchoring + The Annotations Framework binds annotations to the data that the user selects, not just to a position on the display view. Therefore, if the document view changes, such as when the user scrolls or resizes the display window, the annotation stays with the data selection to which it is bound. For example, the following graphic illustrates an annotation that the user has made on a text selection. When the document view changes (scrolls, resizes, scales, or otherwise moves), the highlight annotation moves with the original data selection. ![Annotation Data Anchoring](./media/caf-dataanchoring.png "CAF_DataAnchoring") + ## Matching Annotations with Annotated Objects + You can match annotations with the corresponding annotated objects. For example, consider a simple document reader application that has a comments pane. The comments pane might be a list box that displays the text from a list of annotations that are anchored to a document. If the user selects an item in the list box, then the application brings into view the paragraph in the document that the corresponding annotation object is anchored to. The following example demonstrates how to implement the event handler of such a list box that serves as the comments pane. @@ -69,4 +78,4 @@ Writing notes or comments on paper documents is such a commonplace activity that - [ContextMenu Overview](../controls/contextmenu-overview.md) - [Commanding Overview](commanding-overview.md) - [Flow Document Overview](flow-document-overview.md) -- [How to: Add a Command to a MenuItem](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms741839(v=vs.90)) +- [How to: Add a Command to a MenuItem](/previous-versions/dotnet/netframework-3.5/ms741839(v=vs.90)) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/commanding-overview.md b/dotnet-desktop-guide/framework/wpf/advanced/commanding-overview.md index 92616bc52a..4ab837c79a 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/commanding-overview.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/commanding-overview.md @@ -16,6 +16,7 @@ helpviewer_keywords: ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 --- # Commanding Overview + Commanding is an input mechanism in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] which provides input handling at a more semantic level than device input. Examples of commands are the **Copy**, **Cut**, and **Paste** operations found on many applications. This overview defines what commands are in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)], which classes are part of the commanding model, and how to use and create commands in your applications. @@ -33,7 +34,9 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 - [Creating Custom Commands](#creating_commands) -## What Are Commands? + +## What Are Commands + Commands have several purposes. The first purpose is to separate the semantics and the object that invokes a command from the logic that executes the command. This allows for multiple and disparate sources to invoke the same command logic, and it allows the command logic to be customized for different targets. For example, the editing operations **Copy**, **Cut**, and **Paste**, which are found in many applications, can be invoked by using different user actions if they are implemented by using commands. An application might allow a user to cut selected objects or text by either clicking a button, choosing an item in a menu, or using a key combination, such as CTRL+X. By using commands, you can bind each type of user action to the same logic. Another purpose of commands is to indicate whether an action is available. To continue the example of cutting an object or text, the action only makes sense when something is selected. If a user tries to cut an object or text without having anything selected, nothing would happen. To indicate this to the user, many applications disable buttons and menu items so that the user knows whether it is possible to perform an action. A command can indicate whether an action is possible by implementing the method. A button can subscribe to the event and be disabled if returns `false` or be enabled if returns `true`. @@ -41,7 +44,9 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 The semantics of a command can be consistent across applications and classes, but the logic of the action is specific to the particular object acted upon. The key combination CTRL+X invokes the **Cut** command in text classes, image classes, and Web browsers, but the actual logic for performing the **Cut** operation is defined by the application that performs the cut. A enables clients to implement the logic. A text object may cut the selected text into the clipboard, while an image object may cut the selected image. When an application handles the event, it has access to the target of the command and can take appropriate action depending on the target's type. + ## Simple Command Example in WPF + The simplest way to use a command in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] is to use a predefined from one of the command library classes; use a control that has native support for handling the command; and use a control that has native support for invoking a command. The command is one of the predefined commands in the class. The control has built in logic for handling the command. And the class has native support for invoking commands. The following example shows how to set up a so that when it is clicked it will invoke the command on a , assuming the has keyboard focus. @@ -52,7 +57,9 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 [!code-vb[CommandingOverviewSnippets#CommandingOverviewCommandTargetCodeBehind](~/samples/snippets/visualbasic/VS_Snippets_Wpf/CommandingOverviewSnippets/visualbasic/window1.xaml.vb#commandingoverviewcommandtargetcodebehind)] + ## Four Main Concepts in WPF Commanding + The routed command model in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] can be broken up into four main concepts: the command, the command source, the command target, and the command binding: - The *command* is the action to be executed. @@ -66,7 +73,9 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 In the previous example, the command is the command, the is the command source, the is the command target, and the command binding is supplied by the control. It is worth noting that it is not always the case that the is supplied by the control that is the command target class. Quite often the must be created by the application developer, or the might be attached to an ancestor of the command target. + ### Commands + Commands in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] are created by implementing the interface. exposes two methods, , and , and an event, . performs the actions that are associated with the command. determines whether the command can execute on the current command target. is raised if the command manager that centralizes the commanding operations detects a change in the command source that might invalidate a command that has been raised but not yet executed by the command binding. The [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] implementation of is the class and is the focus of this overview. The main sources of input in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] are the mouse, the keyboard, ink, and routed commands. The more device-oriented inputs use a to notify objects in an application page that an input event has occurred. A is no different. The and methods of a do not contain the application logic for the command, but rather they raise routed events that tunnel and bubble through the element tree until they encounter an object with a . The contains the handlers for these events and it is the handlers that perform the command. For more information on event routing in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)], see [Routed Events Overview](routed-events-overview.md). @@ -76,7 +85,9 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] supplies a set of common routed commands spread across several classes: , , , , and . These classes consist only of the objects and not the implementation logic of the command. The implementation logic is the responsibility of the object on which the command is being executed on. + ### Command Sources + A command source is the object which invokes the command. Examples of command sources are , , and . Command sources in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] generally implement the interface. @@ -119,7 +130,9 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 [!code-vb[CommandingOverviewSnippets#CommandingOverviewKeyGestureOnCmd](~/samples/snippets/visualbasic/VS_Snippets_Wpf/CommandingOverviewSnippets/visualbasic/window1.xaml.vb#commandingoverviewkeygestureoncmd)] + ### CommandBinding + A associates a command with the event handlers that implement the command. The class contains a property, and , , , and events. @@ -146,7 +159,9 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 In some situations the is attached to the command target itself, such as with the class and the , , and commands. Quite often though, it is more convenient to attach the to an ancestor of the command target, such as the main or the Application object, especially if the same can be used for multiple command targets. These are design decisions you will want to consider when you are creating your commanding infrastructure. + ### Command Target + The command target is the element on which the command is executed. With regards to a , the command target is the element at which routing of the and starts. As noted previously, in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] the property on is only applicable when the is a . If the is set on an and the corresponding command is not a , the command target is ignored. The command source can explicitly set the command target. If the command target is not defined, the element with keyboard focus will be used as the command target. One of the benefits of using the element with keyboard focus as the command target is that it allows the application developer to use the same command source to invoke a command on multiple targets without having to keep track of the command target. For example, if a invokes the **Paste** command in an application that has a control and a control, the target can be either the or depending on which control has keyboard focus. @@ -159,13 +174,17 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 [!code-vb[CommandingOverviewSnippets#CommandingOverviewCommandTargetCodeBehind](~/samples/snippets/visualbasic/VS_Snippets_Wpf/CommandingOverviewSnippets/visualbasic/window1.xaml.vb#commandingoverviewcommandtargetcodebehind)] + ### The CommandManager + The serves a number of command related functions. It provides a set of static methods for adding and removing , , , and event handlers to and from a specific element. It provides a means to register and objects onto a specific class. The also provides a means, through the event, to notify a command when it should raise the event. The method forces the to raise the event. This is useful for conditions that should disable/enable a command but are not conditions that the is aware of. + ## Command Library + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] provides a set of predefined commands. The command library consists of the following classes: , , , , and the . These classes provide commands such as , and , , , and . Many of these commands include a set of default input bindings. For example, if you specify that your application handles the copy command, you automatically get the keyboard binding "CTRL+C" You also get bindings for other input devices, such as Tablet PC pen gestures and speech information. @@ -173,7 +192,9 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 When you reference commands in the various command libraries using [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)], you can usually omit the class name of the library class that exposes the static command property. Generally, the command names are unambiguous as strings, and the owning types exist to provide a logical grouping of commands but are not necessary for disambiguation. For instance, you can specify `Command="Cut"` rather than the more verbose `Command="ApplicationCommands.Cut"`. This is a convenience mechanism that is built in to the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] processor for commands (more precisely, it is a type converter behavior of , which the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] processor references at load time). + ## Creating Custom Commands + If the commands in the command library classes do not meet your needs, then you can create your own commands. There are two ways to create a custom command. The first is to start from the ground up and implement the interface. The other way, and the more common approach, is to create a or a . For an example of creating a custom , see [Create a Custom RoutedCommand Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Input%20and%20Commands/CustomRoutedCommand). @@ -187,5 +208,5 @@ ms.assetid: bc208dfe-367d-426a-99de-52b7e7511e81 - [Input Overview](input-overview.md) - [Routed Events Overview](routed-events-overview.md) - [Implement ICommandSource](how-to-implement-icommandsource.md) -- [How to: Add a Command to a MenuItem](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms741839(v=vs.90)) +- [How to: Add a Command to a MenuItem](/previous-versions/dotnet/netframework-3.5/ms741839(v=vs.90)) - [Create a Custom RoutedCommand Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Input%20and%20Commands/CustomRoutedCommand) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/creating-an-ink-input-control.md b/dotnet-desktop-guide/framework/wpf/advanced/creating-an-ink-input-control.md index 5e5aee3c17..953f425d8f 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/creating-an-ink-input-control.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/creating-an-ink-input-control.md @@ -16,6 +16,7 @@ helpviewer_keywords: ms.assetid: c31f3a67-cb3f-4ded-af9e-ed21f6575b26 --- # Creating an Ink Input Control + You can create a custom control that dynamically and statically renders ink. That is, render ink as a user draws a stroke, causing the ink to appear to "flow" from the tablet pen, and display ink after it is added to the control, either via the tablet pen, pasted from the Clipboard, or loaded from a file. To dynamically render ink, your control must use a . To statically render ink, you must override the stylus event methods (, , and ) to collect data, create strokes, and add them to an (which renders the ink on the control). This topic contains the following subsections: @@ -31,7 +32,9 @@ You can create a custom control that dynamically and statically renders ink. Tha - [Conclusion](#AdvancedInkHandling_Conclusion) + ## How to: Collect Stylus Point Data and Create Ink Strokes + To create a control that collects and manages ink strokes do the following: 1. Derive a class from or one of the classes derived from , such as . @@ -62,7 +65,9 @@ You can create a custom control that dynamically and statically renders ink. Tha [!code-csharp[AdvancedInkTopicsSamples#10](~/samples/snippets/csharp/VS_Snippets_Wpf/AdvancedInkTopicsSamples/CSharp/StylusControl.cs#10)] + ## How to: Enable Your Control to Accept Input from the Mouse + If you add the preceding control to your application, run it, and use the mouse as an input device, you will notice that the strokes are not persisted. To persist the strokes when the mouse is used as the input device do the following: 1. Override the and create a new Get the position of the mouse when the event occurred and create a using the point data and add the to the . @@ -78,21 +83,27 @@ You can create a custom control that dynamically and statically renders ink. Tha [!code-csharp[AdvancedInkTopicsSamples#13](~/samples/snippets/csharp/VS_Snippets_Wpf/AdvancedInkTopicsSamples/CSharp/StylusControl.cs#13)] + ## Putting it together + The following example is a custom control that collects ink when the user uses either the mouse or the pen. [!code-csharp[AdvancedInkTopicsSamples#20](~/samples/snippets/csharp/VS_Snippets_Wpf/AdvancedInkTopicsSamples/CSharp/StylusControl.cs#20)] [!code-csharp[AdvancedInkTopicsSamples#6](~/samples/snippets/csharp/VS_Snippets_Wpf/AdvancedInkTopicsSamples/CSharp/StylusControl.cs#6)] + ## Using Additional Plug-ins and DynamicRenderers + Like the InkCanvas, your custom control can have custom and additional objects. Add these to the collection. The order of the objects in the affects the appearance of the ink when it is rendered. Suppose you have a called `dynamicRenderer` and a custom called `translatePlugin` that offsets the ink from the tablet pen. If `translatePlugin` is the first in the , and `dynamicRenderer` is the second, the ink that "flows" will be offset as the user moves the pen. If `dynamicRenderer` is first, and `translatePlugin` is second, the ink will not be offset until the user lifts the pen. + ## Conclusion + You can create a control that collects and renders ink by overriding the stylus event methods. By creating your own control, deriving your own classes, and inserting them the into , you can implement virtually any behavior imaginable with digital ink. You have access to the data as it is generated, giving you the opportunity to customize input and render it on the screen as appropriate for your application. Because you have such low-level access to the data, you can implement ink collection and render it with optimal performance for your application. ## See also - [Advanced Ink Handling](advanced-ink-handling.md) -- [Accessing and Manipulating Pen Input](https://docs.microsoft.com/previous-versions/ms818317(v=msdn.10)) +- [Accessing and Manipulating Pen Input](/previous-versions/ms818317(v=msdn.10)) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/documents.md b/dotnet-desktop-guide/framework/wpf/advanced/documents.md index b9d534ec81..368e3bd49e 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/documents.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/documents.md @@ -8,9 +8,11 @@ helpviewer_keywords: ms.assetid: 7bf37ccb-5d09-4eae-9661-929582aeb259 --- # Documents + [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] provides a versatile set of components that enable developers to build applications with advanced document features and an improved reading experience. In addition to enhanced capabilities and quality, [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] also provides simplified management services for document packaging, security, and storage. ## In This Section + [Documents in WPF](documents-in-wpf.md) [Document Serialization and Storage](document-serialization-and-storage.md) [Annotations](annotations.md) @@ -23,4 +25,4 @@ ms.assetid: 7bf37ccb-5d09-4eae-9661-929582aeb259 - - - -- [isXPS.exe (isXPS Conformance Tool)](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/aa348104(v=vs.100)) +- [isXPS.exe (isXPS Conformance Tool)](/previous-versions/dotnet/netframework-4.0/aa348104(v=vs.100)) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/drawing-formatted-text.md b/dotnet-desktop-guide/framework/wpf/advanced/drawing-formatted-text.md index e8ace9a04c..787cfb86fb 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/drawing-formatted-text.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/drawing-formatted-text.md @@ -12,9 +12,11 @@ helpviewer_keywords: ms.assetid: b1d851c1-331c-4814-9964-6fe769db6f1f --- # Drawing Formatted Text + This topic provides an overview of the features of the object. This object provides low-level control for drawing text in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] applications. ## Technology Overview + The object allows you to draw multi-line text, in which each character in the text can be individually formatted. The following example shows text that has several formats applied to it. ![Text displayed using FormattedText object](./media/typography-in-wpf/text-formatted-linear-gradient.jpg) @@ -23,6 +25,7 @@ This topic provides an overview of the features of the For those developers migrating from the Win32 API, the table in the [Win32 Migration](#win32_migration) section lists the Win32 DrawText flags and the approximate equivalent in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)]. ### Reasons for Using Formatted Text + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] includes multiple controls for drawing text to the screen. Each control is targeted to a different scenario and has its own list of features and limitations. In general, the element should be used when limited text support is required, such as a brief sentence in a [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)]. can be used when minimal text support is required. For more information, see [Documents in WPF](documents-in-wpf.md). The object provides greater text formatting features than [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] text controls, and can be useful in cases where you want to use text as a decorative element. For more information, see the following section [Converting Formatted Text to a Geometry](#converting_formatted_text). @@ -30,6 +33,7 @@ This topic provides an overview of the features of the object is useful for creating text-oriented -derived objects. is a lightweight drawing class that is used to render shapes, images, or text. For more information, see [Hit Test Using DrawingVisuals Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Visual%20Layer/DrawingVisual). ## Using the FormattedText Object + To create formatted text, call the constructor to create a object. Once you have created the initial formatted text string, you can apply a range of formatting styles. Use the property to constrain the text to a specific width. The text will automatically wrap to avoid exceeding the specified width. Use the property to constrain the text to a specific height. The text will display an ellipsis, "…" for the text that exceeds the specified height. @@ -44,13 +48,16 @@ This topic provides an overview of the features of the object uses device-independent pixels as the unit of measure. However, most Win32 applications use points as the unit of measure. If you want to use display text in units of points in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] applications, you need to convert device-independent units (1/96th inch per unit) to points. The following code example shows how to perform this conversion. [!code-csharp[FormattedTextSnippets#FormattedTextSnippets2](~/samples/snippets/csharp/VS_Snippets_Wpf/FormattedTextSnippets/CSharp/Window1.xaml.cs#formattedtextsnippets2)] [!code-vb[FormattedTextSnippets#FormattedTextSnippets2](~/samples/snippets/visualbasic/VS_Snippets_Wpf/FormattedTextSnippets/visualbasic/window1.xaml.vb#formattedtextsnippets2)] + ### Converting Formatted Text to a Geometry + You can convert formatted text into objects, allowing you to create other types of visually interesting text. For example, you could create a object based on the outline of a text string. ![Text outline using a linear gradient brush](./media/typography-in-wpf/text-outline-linear-gradient.jpg) @@ -72,14 +79,16 @@ This topic provides an overview of the features of the object. For example, you can clip video to display inside it. ![Video displaying in the path geometry of text](./media/drawing-formatted-text/video-displaying-text-path-geometry.png) + ## Win32 Migration + The features of for drawing text are similar to the features of the Win32 DrawText function. For those developers migrating from the Win32 API, the following table lists the Win32 DrawText flags and the approximate equivalent in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)]. |DrawText flag|WPF equivalent|Notes| @@ -115,4 +124,4 @@ Sphere following the path geometry of text - [Documents in WPF](documents-in-wpf.md) - [Typography in WPF](typography-in-wpf.md) - [Create Outlined Text](how-to-create-outlined-text.md) -- [How to: Create a PathGeometry Animation for Text](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms743610(v=vs.100)) +- [How to: Create a PathGeometry Animation for Text](/previous-versions/dotnet/netframework-4.0/ms743610(v=vs.100)) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/graphics-rendering-tiers.md b/dotnet-desktop-guide/framework/wpf/advanced/graphics-rendering-tiers.md index a9e1d95ff4..bf917bc2cc 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/graphics-rendering-tiers.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/graphics-rendering-tiers.md @@ -10,10 +10,13 @@ helpviewer_keywords: ms.assetid: 08dd1606-02a2-4122-9351-c0afd2ec3a70 --- # Graphics Rendering Tiers + A rendering tier defines a level of graphics hardware capability and performance for a device that runs a [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] application. + ## Graphics Hardware + The features of the graphics hardware that most impact the rendering tier levels are: - **Video RAM** The amount of video memory on the graphics hardware determines the size and number of buffers that can be used for compositing graphics. @@ -25,7 +28,9 @@ A rendering tier defines a level of graphics hardware capability and performance - **Multitexture Support** Multitexture support refers to the ability to apply two or more distinct textures during a blending operation on a 3D graphics object. The degree of multitexture support is determined by the number of multitexture units on the graphics hardware. + ## Rendering Tier Definitions + The features of the graphics hardware determine the rendering capability of a [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] application. The [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] system defines three rendering tiers: - **Rendering Tier 0** No graphics hardware acceleration. All graphics features use software acceleration. The DirectX version level is less than version 9.0. @@ -37,6 +42,7 @@ A rendering tier defines a level of graphics hardware capability and performance The property allows you to retrieve the rendering tier at application run time. You use the rendering tier to determine whether the device supports certain hardware-accelerated graphics features. Your application can then take different code paths at run time depending on the rendering tier supported by the device. ### Rendering Tier 0 + A rendering tier value of 0 means that there is no graphics hardware acceleration available for the application on the device. At this tier level, you should assume that all graphics will be rendered by software with no hardware acceleration. This tier's functionality corresponds to a DirectX version that is less than 9.0. ### Rendering Tier 1 and Rendering Tier 2 @@ -82,14 +88,17 @@ A rendering tier defines a level of graphics hardware capability and performance |Rasterized content that uses |Any content rendered by using the method of .| |Tiled content that uses |Any tiled content in which the property of the is set to .| |Surfaces that exceed the maximum texture size of the graphics hardware|For most graphics hardware, large surfaces are 2048x2048 or 4096x4096 pixels in size.| -|Any operation whose video RAM requirement exceeds the memory of the graphics hardware|You can monitor application video RAM usage by using the Perforator tool that is included in the [WPF Performance Suite](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/aa969767(v=vs.100)) in the Windows SDK.| +|Any operation whose video RAM requirement exceeds the memory of the graphics hardware|You can monitor application video RAM usage by using the Perforator tool that is included in the [WPF Performance Suite](/previous-versions/dotnet/netframework-4.0/aa969767(v=vs.100)) in the Windows SDK.| |Layered windows|Layered windows allow [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications to render content to the screen in a non-rectangular window. On operating systems that support Windows Display Driver Model (WDDM), such as Windows Vista and Windows 7, layered windows are hardware accelerated. On other systems, such as Windows XP, layered windows are rendered by software with no hardware acceleration.

You can enable layered windows in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] by setting the following properties:

- =
- = `true`
- = | + ## Other Resources + The following resources can help you analyze the performance characteristics of your [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] application. ### Graphics Rendering Registry Settings + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] provides four registry settings for controlling [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] rendering: |Setting|Description| @@ -102,6 +111,7 @@ A rendering tier defines a level of graphics hardware capability and performance These settings can be accessed by any external configuration utility that knows how to reference the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] registry settings. These settings can also be created or modified by accessing the values directly by using the Windows Registry Editor. For more information, see [Graphics Rendering Registry Settings](../graphics-multimedia/graphics-rendering-registry-settings.md). ### WPF Performance Profiling Tools + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] provides a suite of performance profiling tools that allow you to analyze the run-time behavior of your application and determine the types of performance optimizations you can apply. The following table lists the performance profiling tools that are included in the Windows SDK tool, WPF Performance Suite: |Tool|Description| @@ -109,9 +119,10 @@ A rendering tier defines a level of graphics hardware capability and performance |Perforator|Use for analyzing rendering behavior.| |Visual Profiler|Use for profiling the use of [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] services, such as layout and event handling, by elements in the visual tree.| - The WPF Performance Suite provides a rich, graphical view of performance data. For more information about WPF performance tools, see [WPF Performance Suite](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/aa969767(v=vs.100)). + The WPF Performance Suite provides a rich, graphical view of performance data. For more information about WPF performance tools, see [WPF Performance Suite](/previous-versions/dotnet/netframework-4.0/aa969767(v=vs.100)). ### DirectX Diagnostic Tool + The DirectX Diagnostic Tool, Dxdiag.exe, is designed to help you troubleshoot DirectX-related issues. The default installation folder for the DirectX Diagnostic Tool is: `~\Windows\System32` @@ -126,6 +137,6 @@ DirectX Diagnostic Tool main window - - - [Optimizing WPF Application Performance](optimizing-wpf-application-performance.md) -- [WPF Performance Suite](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/aa969767(v=vs.100)) +- [WPF Performance Suite](/previous-versions/dotnet/netframework-4.0/aa969767(v=vs.100)) - [Graphics Rendering Registry Settings](../graphics-multimedia/graphics-rendering-registry-settings.md) - [Animation Tips and Tricks](../graphics-multimedia/animation-tips-and-tricks.md) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/handwriting-recognition.md b/dotnet-desktop-guide/framework/wpf/advanced/handwriting-recognition.md index 42df4d0dac..756a7a4fe7 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/handwriting-recognition.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/handwriting-recognition.md @@ -10,10 +10,12 @@ helpviewer_keywords: ms.assetid: f4e8576d-e731-4bac-9818-22e2ae636636 --- # Handwriting Recognition + This section discusses the fundamentals of recognition as it pertains to digital ink in the WPF platform. ## Recognition Solutions - The following example shows how to recognize ink using the [Microsoft.Ink.InkCollector](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) class. + + The following example shows how to recognize ink using the [Microsoft.Ink.InkCollector](/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) class. > [!NOTE] > This sample requires that handwriting recognizers be installed on the system. @@ -29,4 +31,4 @@ This section discusses the fundamentals of recognition as it pertains to digital ## See also -- [Microsoft.Ink.InkCollector](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) +- [Microsoft.Ink.InkCollector](/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/how-to-analyze-ink-with-analysis-hints.md b/dotnet-desktop-guide/framework/wpf/advanced/how-to-analyze-ink-with-analysis-hints.md index e157d2c75b..09e2c8818c 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/how-to-analyze-ink-with-analysis-hints.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/how-to-analyze-ink-with-analysis-hints.md @@ -12,10 +12,12 @@ helpviewer_keywords: ms.assetid: d4421ed4-77f5-4640-829e-9f1de50b2ff2 --- # How to: Analyze Ink with Analysis Hints -An [System.Windows.Ink.AnalysisHintNode](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms610344(v=vs.90)) provides a hint for the [System.Windows.Ink.InkAnalyzer](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms616754(v=vs.90)) to which it is attached. The hint applies to the area specified by the [System.Windows.Ink.ContextNode.Location%2A](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms594508(v=vs.90)) property of the [System.Windows.Ink.AnalysisHintNode](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms610344(v=vs.90)) and provides extra context to the ink analyzer to improve recognition accuracy. The [System.Windows.Ink.InkAnalyzer](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms616754(v=vs.90)) applies this context information when analyzing ink obtained from within the hint's area. + +An [System.Windows.Ink.AnalysisHintNode](/previous-versions/dotnet/netframework-3.5/ms610344(v=vs.90)) provides a hint for the [System.Windows.Ink.InkAnalyzer](/previous-versions/dotnet/netframework-3.5/ms616754(v=vs.90)) to which it is attached. The hint applies to the area specified by the [System.Windows.Ink.ContextNode.Location%2A](/previous-versions/dotnet/netframework-3.5/ms594508(v=vs.90)) property of the [System.Windows.Ink.AnalysisHintNode](/previous-versions/dotnet/netframework-3.5/ms610344(v=vs.90)) and provides extra context to the ink analyzer to improve recognition accuracy. The [System.Windows.Ink.InkAnalyzer](/previous-versions/dotnet/netframework-3.5/ms616754(v=vs.90)) applies this context information when analyzing ink obtained from within the hint's area. ## Example - The following example is an application that uses multiple [System.Windows.Ink.AnalysisHintNode](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms610344(v=vs.90)) objects on a form that accepts ink input. The application uses the [System.Windows.Ink.AnalysisHintNode.Factoid%2A](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms594341(v=vs.90)) property to provide context information for each entry on the form. The application uses background analysis to analyze the ink and clears the form of all ink five seconds after the user stops adding ink. + + The following example is an application that uses multiple [System.Windows.Ink.AnalysisHintNode](/previous-versions/dotnet/netframework-3.5/ms610344(v=vs.90)) objects on a form that accepts ink input. The application uses the [System.Windows.Ink.AnalysisHintNode.Factoid%2A](/previous-versions/dotnet/netframework-3.5/ms594341(v=vs.90)) property to provide context information for each entry on the form. The application uses background analysis to analyze the ink and clears the form of all ink five seconds after the user stops adding ink. [!code-xaml[HowToAnalyzeInk#1](~/samples/snippets/csharp/VS_Snippets_Wpf/HowToAnalyzeInk/CSharp/FormAnalyzer.xaml#1)] diff --git a/dotnet-desktop-guide/framework/wpf/advanced/how-to-enable-visual-styles-in-a-hybrid-application.md b/dotnet-desktop-guide/framework/wpf/advanced/how-to-enable-visual-styles-in-a-hybrid-application.md index 78954e8ab9..65f5574e2e 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/how-to-enable-visual-styles-in-a-hybrid-application.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/how-to-enable-visual-styles-in-a-hybrid-application.md @@ -10,11 +10,12 @@ helpviewer_keywords: ms.assetid: 95de9b9c-d804-405c-b2d1-49a88c1e0fe1 --- # How to: Enable Visual Styles in a Hybrid Application + This topic shows how to enable visual styles on a Windows Forms control hosted in a [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]-based application. If your application calls the method, most of your Windows Forms controls will automatically use visual styles. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - For a complete code listing of the tasks illustrated in this topic, see [Enabling Visual Styles in a Hybrid Application Sample](https://go.microsoft.com/fwlink/?LinkID=159986). + For a complete code listing of the tasks illustrated in this topic, see [Enabling Visual Styles in a Hybrid Application Sample](https://github.com/microsoft/WPF-Samples/tree/master/Migration%20and%20Interoperability/HostingWfWithVisualStyles). ## Enabling Windows Forms Visual Styles @@ -48,6 +49,7 @@ This topic shows how to enable visual styles on a Windows Forms control hosted i The Windows Forms control is painted with visual styles. ## Disabling Windows Forms Visual Styles + To disable visual styles, simply remove the call to the method. #### To disable Windows Forms visual styles diff --git a/dotnet-desktop-guide/framework/wpf/advanced/how-to-programmatically-print-xps-files.md b/dotnet-desktop-guide/framework/wpf/advanced/how-to-programmatically-print-xps-files.md index a01d561727..e302274a59 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/how-to-programmatically-print-xps-files.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/how-to-programmatically-print-xps-files.md @@ -13,7 +13,7 @@ ms.assetid: 0b1c0a3f-b19e-43d6-bcc9-eb3ec4e555ad You can use one overload of the method to print XML Paper Specification (XPS) files without opening a or, in principle, any [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)] at all. -You can also print XPS files using the many and methods. For more information, see [Printing an XPS Document](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms771525(v=vs.90)). +You can also print XPS files using the many and methods. For more information, see [Printing an XPS Document](/previous-versions/dotnet/netframework-3.5/ms771525(v=vs.90)). Another way of printing XPS is to use the or methods. See [Invoke a Print Dialog](how-to-invoke-a-print-dialog.md). @@ -53,7 +53,7 @@ where *\* is any print queue. The machine must then be reboote This disguise will enable you to pass `true` as the final parameter of without causing an exception, but since *\* is not really an XPSDrv printer, only garbage will print. > [!NOTE] -> For simplicity, the example above uses the presence of an \*.xps extension as its test that a file is XPS. However, XPS files do not have to have this extension. The [isXPS.exe (isXPS Conformance Tool)](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/aa348104(v=vs.100)) is one way of testing a file for XPS validity. +> For simplicity, the example above uses the presence of an \*.xps extension as its test that a file is XPS. However, XPS files do not have to have this extension. The [isXPS.exe (isXPS Conformance Tool)](/previous-versions/dotnet/netframework-4.0/aa348104(v=vs.100)) is one way of testing a file for XPS validity. ## See also @@ -62,8 +62,8 @@ This disguise will enable you to pass `true` as the final parameter of - - [XPS Documents](/windows/desktop/printdocs/documents) -- [Printing an XPS Document](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms771525(v=vs.90)) -- [Managed and Unmanaged Threading](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/5s8ee185(v=vs.100)) -- [isXPS.exe (isXPS Conformance Tool)](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/aa348104(v=vs.100)) +- [Printing an XPS Document](/previous-versions/dotnet/netframework-3.5/ms771525(v=vs.90)) +- [Managed and Unmanaged Threading](/previous-versions/dotnet/netframework-4.0/5s8ee185(v=vs.100)) +- [isXPS.exe (isXPS Conformance Tool)](/previous-versions/dotnet/netframework-4.0/aa348104(v=vs.100)) - [Documents in WPF](documents-in-wpf.md) - [Printing Overview](printing-overview.md) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/how-to-use-a-thicknessconverter-object.md b/dotnet-desktop-guide/framework/wpf/advanced/how-to-use-a-thicknessconverter-object.md index 08b50b585d..14c033bbbb 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/how-to-use-a-thicknessconverter-object.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/how-to-use-a-thicknessconverter-object.md @@ -10,7 +10,9 @@ helpviewer_keywords: ms.assetid: 52682194-d7fd-499c-8005-73fcc84e7b2c --- # How to: Use a ThicknessConverter Object + ## Example + This example shows how to create an instance of and use it to change the thickness of a border. The example defines a custom method called `changeThickness`; this method first converts the contents of a , as defined in a separate [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] file, to an instance of , and later converts the content into a . This method passes the to a object, which converts the of a to an instance of . This value is then passed back as the value of the property of the . @@ -25,6 +27,6 @@ ms.assetid: 52682194-d7fd-499c-8005-73fcc84e7b2c - - - -- [How to: Change the Margin Property](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms750561(v=vs.90)) -- [How to: Convert a ListBoxItem to a new Data Type](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms749147(v=vs.90)) +- [How to: Change the Margin Property](/previous-versions/dotnet/netframework-3.5/ms750561(v=vs.90)) +- [How to: Convert a ListBoxItem to a new Data Type](/previous-versions/dotnet/netframework-3.5/ms749147(v=vs.90)) - [Panels Overview](../controls/panels-overview.md) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/intercepting-input-from-the-stylus.md b/dotnet-desktop-guide/framework/wpf/advanced/intercepting-input-from-the-stylus.md index 5e2899a0d0..1d4a326713 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/intercepting-input-from-the-stylus.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/intercepting-input-from-the-stylus.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: 791bb2f0-4e5c-4569-ac3c-211996808d44 --- # Intercepting Input from the Stylus + The architecture provides a mechanism for implementing low-level control over input and the creation of digital ink objects. The class provides a mechanism for you to implement custom behavior and apply it to the stream of data coming from the stylus device for the optimal performance. This topic contains the following subsections: @@ -25,15 +26,19 @@ The architecture provides a mechanism - [Conclusion](#Conclusion) + ## Architecture - The is the evolution of the [StylusInput](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms574861(v=vs.90)) APIs, described in [Accessing and Manipulating Pen Input](https://docs.microsoft.com/previous-versions/ms818317(v%3dmsdn.10)). + + The is the evolution of the [StylusInput](/previous-versions/dotnet/netframework-3.5/ms574861(v=vs.90)) APIs, described in [Accessing and Manipulating Pen Input](/previous-versions/ms818317(v%3dmsdn.10)). Each has a property that is a . You can add a to an element's property to manipulate data as it is generated. data consists of all the properties supported by the system digitizer, including the and point data, as well as data. Your objects are inserted directly into the stream of data coming from the device when you add the to the property. The order in which plug-ins are added to the collection dictates the order in which they will receive data. For example, if you add a filter plug-in that restricts input to a particular region, and then add a plug-in that recognizes gestures as they are written, the plug-in that recognizes gestures will receive filtered data. + ## Implementing Stylus Plug-ins + To implement a plug-in, derive a class from . This class is applied o the stream of data as it comes in from the . In this class you can modify the values of the data. > [!CAUTION] @@ -47,7 +52,9 @@ The architecture provides a mechanism [!code-vb[AdvancedInkTopicsSamples#3](~/samples/snippets/visualbasic/VS_Snippets_Wpf/AdvancedInkTopicsSamples/VisualBasic/DynamicRenderer.vb#3)] + ## Adding Your Plug-in to an InkCanvas + The easiest way to use your custom plug-in is to implement a class that derives from InkCanvas and add it to the property. The following example demonstrates a custom that filters the ink. @@ -61,10 +68,12 @@ The architecture provides a mechanism [!code-csharp[AdvancedInkTopicsSamples#5](~/samples/snippets/csharp/VS_Snippets_Wpf/AdvancedInkTopicsSamples/CSharp/Window1.xaml.cs#5)] + ## Conclusion + By deriving your own classes and inserting them into collections, you can greatly enhance the behavior of your digital ink. You have access to the data as it is generated, giving you the opportunity to customize the input. Because you have such low-level access to the data, you can implement ink collection and rendering with optimal performance for your application. ## See also - [Advanced Ink Handling](advanced-ink-handling.md) -- [Accessing and Manipulating Pen Input](https://docs.microsoft.com/previous-versions/ms818317(v%3dmsdn.10)) +- [Accessing and Manipulating Pen Input](/previous-versions/ms818317(v%3dmsdn.10)) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/mc-processcontent-attribute.md b/dotnet-desktop-guide/framework/wpf/advanced/mc-processcontent-attribute.md index 81ec51bf6e..cfb3cb0c57 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/mc-processcontent-attribute.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/mc-processcontent-attribute.md @@ -7,6 +7,7 @@ helpviewer_keywords: ms.assetid: 2689b2c8-b4dc-4b71-b9bd-f95e619122d7 --- # mc:ProcessContent Attribute + Specifies which [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] elements should still have content processed by relevant parent elements, even if the immediate parent element may be ignored by a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] processor due to specifying [mc:Ignorable Attribute](mc-ignorable-attribute.md). The `mc:ProcessContent` attribute supports markup compatibility both for custom namespace mapping and for [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] versioning. ## XAML Attribute Usage @@ -34,11 +35,12 @@ Specifies which [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md. |*[content]*|*ThisElementCanBeIgnored* is marked ignorable. If the processor ignores that element, *[content]* is processed by *object*.| ## Remarks + By default, a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] processor will ignore content within an ignored element. You can specify a specific element by `mc:ProcessContent`, and a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] processor will continue to process the content within the ignored element. This would typically be used if the content is nested within several tags, at least one of which is ignorable and at least one of which is not ignorable. Multiple prefixes may be specified in the attribute, using a space separator, for example: `mc:ProcessContent="ignore:Element1 ignore:Element2"`. - The `http://schemas.openxmlformats.org/markup-compatibility/2006` namespace defines other elements and attributes that are not documented within this area of the SDK. For more information, see [XML Markup Compatibility Specification](https://docs.microsoft.com/office/open-xml/introduction-to-markup-compatibility#markup-compatibility-in-the-open-xml-file-formats-specification). + The `http://schemas.openxmlformats.org/markup-compatibility/2006` namespace defines other elements and attributes that are not documented within this area of the SDK. For more information, see [XML Markup Compatibility Specification](/office/open-xml/introduction-to-markup-compatibility#markup-compatibility-in-the-open-xml-file-formats-specification). ## See also diff --git a/dotnet-desktop-guide/framework/wpf/advanced/opentype-font-features.md b/dotnet-desktop-guide/framework/wpf/advanced/opentype-font-features.md index e9e4cf27a5..fd46c54a40 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/opentype-font-features.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/opentype-font-features.md @@ -15,7 +15,9 @@ ms.assetid: 4061a9d1-fe8b-4921-9e17-18ec7d2e3ea2 This topic provides an overview of some of the key features of OpenType font technology in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)]. + ## OpenType Font Format + The OpenType font format is an extension of the TrueType® font format, adding support for PostScript font data. The OpenType font format was developed jointly by Microsoft and Adobe Corporation. OpenType fonts and the operating system services which support OpenType fonts provide users with a simple way to install and use fonts, whether the fonts contain TrueType outlines or CFF (PostScript) outlines. The OpenType font format addresses the following developer challenges: @@ -33,9 +35,10 @@ This topic provides an overview of some of the key features of OpenType font tec > [!NOTE] > The Windows SDK contains a set of sample OpenType fonts that you can use with [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] applications. These fonts provide most of the features illustrated in the rest of this topic. For more information, see [Sample OpenType Font Pack](sample-opentype-font-pack.md). -For details of the OpenType font format, see the [OpenType specification](https://docs.microsoft.com/typography/opentype/spec/). +For details of the OpenType font format, see the [OpenType specification](/typography/opentype/spec/). ### Advanced Typographic Extensions + The Advanced Typographic tables (OpenType Layout tables) extend the functionality of fonts with either TrueType or CFF outlines. OpenType Layout fonts contain additional information that extends the capabilities of the fonts to support high-quality international typography. Most OpenType fonts expose only a subset of the total OpenType features available. OpenType fonts provide the following features. - Rich mapping between characters and glyphs that support ligatures, positional forms, alternates, and other font substitutions. @@ -49,10 +52,13 @@ For details of the OpenType font format, see the [OpenType specification](https: The remainder of this overview introduces the breadth and flexibility of some of the visually-interesting OpenType features that are exposed by the properties of the object. For more information on this object, see [Typography Class](#typography_class). + ## Variants + Variants are used to render different typographic styles, such as superscripts and subscripts. ### Superscripts and Subscripts + The property allows you to set superscript and subscript values for an OpenType font. The following text displays superscripts for the Palatino Linotype font. @@ -72,6 +78,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#13](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#13)] ### Decorative Uses of Superscripts and Subscripts + You can also use superscripts and subscripts to create decorative effects of mixed case text. The following text displays superscript and subscript text for the Palatino Linotype font. Note that the capitals are not affected. ![Text using OpenType superscripts and subscripts](./media/opentype-font-features/opentype-superscripts-subscripts.gif "Text using OpenType superscripts and subscripts") @@ -81,7 +88,9 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#14](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#14)] + ## Capitals + Capitals are a set of typographical forms that render text in capital-styled glyphs. Typically, when text is rendered as all capitals, the spacing between letters can appear too tight, and the weight and proportion of the letters too heavy. OpenType supports a number of styling formats for capitals, including small capitals, petite capitals, titling, and capital spacing. These styling formats allow you to control the appearance of capitals. The following text displays standard capital letters for the Pescadero font, followed by the letters styled as "SmallCaps" and "AllSmallCaps". In this case, the same font size is used for all three words. @@ -93,6 +102,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#9](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#9)] ### Titling Capitals + Titling capitals are lighter in weight and proportion and designed to give a more elegant look than normal capitals. Titling capitals are typically used in larger font sizes as headings. The following text displays normal and titling capitals for the Pescadero font. Notice the narrower stem widths of the text on the second line. ![Text using OpenType titling capitals](./media/opentype-font-features/opentype-titling-capitals.gif "Text using OpenType titling capitals") @@ -102,6 +112,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#OpenTypeFontSnippet17](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#opentypefontsnippet17)] ### Capital Spacing + Capital spacing is a feature that allows you to provide more spacing when using all capitals in text. Capital letters are typically designed to blend with lowercase letters. Spacing that appears attractive between and a capital letter and a lowercase letter may look too tight when all capital letters are used. The following text displays normal and capital spacing for the Pescadero font. ![Text using OpenType capital spacing](./media/opentype-font-features/opentype-capital-spacing.gif "Text using OpenType capital spacing ") @@ -111,7 +122,9 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#OpenTypeFontSnippet18](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#opentypefontsnippet18)] + ## Ligatures + Ligatures are two or more glyphs that are formed into a single glyph in order to create more readable or attractive text. OpenType fonts support four types of ligatures: - **Standard ligatures**. Designed to enhance readability. Standard ligatures include "fi", "fl", and "ff". @@ -151,7 +164,9 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#6](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#6)] + ## Swashes + Swashes are decorative glyphs that use elaborate ornamentation often associated with calligraphy. The following text displays standard and swash glyphs for the Pescadero font. ![Text using OpenType standard and swash glyphs](./media/opentype-font-features/opentype-standard-swash-glyphs.gif "Text using OpenType standard and swash glyphs") @@ -165,6 +180,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#7](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#7)] ### Contextual Swashes + Certain combinations of swash glyphs can cause an unattractive appearance, such as overlapping descenders on adjacent letters. Using a contextual swash allows you to use a substitute swash glyph that produces a better appearance. The following text shows the same word before and after a contextual swash is applied. ![Text using OpenType contextual swashes](./media/opentype-font-features/opentype-contextual-swashes.gif "Text using OpenType contextual swashes") @@ -174,7 +190,9 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#OpenTypeFontSnippet16](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#opentypefontsnippet16)] + ## Alternates + Alternates are glyphs that can be substituted for a standard glyph. OpenType fonts, such as the Pericles font used in the following examples, can contain alternate glyphs that you can use to create different appearances for text. The following text displays standard glyphs for the Pericles font. ![Text using OpenType standard glyphs](./media/opentype-font-features/opentype-standard-glyphs.gif "Text using OpenType standard glyphs") @@ -196,6 +214,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#3](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#3)] ### Random Contextual Alternates + Random contextual alternates provide multiple substitute glyphs for a single character. When implemented with script-type fonts, this feature can simulate handwriting by using of a set of randomly chosen glyphs with slight differences in appearance. The following text uses random contextual alternates for the Lindsey font. Notice that the letter "a" varies slightly in appearance ![Text using OpenType random contextual alternates](./media/opentype-font-features/opentype-random-contextual-alternates.gif "Text using OpenType random contextual alternates") @@ -205,6 +224,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#OpenTypeFontSnippet20](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/Window1.xaml#opentypefontsnippet20)] ### Historical Forms + Historical forms are typographic conventions that were common in the past. The following text displays the phrase, "Boston, Massachusetts", using an historical form of glyphs for the Palatino Linotype font. ![Text using OpenType historical forms](./media/opentype-font-features/opentype-historical-forms.gif "Text using OpenType historical forms") @@ -214,10 +234,13 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#8](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#8)] + ## Numerical Styles + OpenType fonts support a large number of features that can be used with numerical values in text. ### Fractions + OpenType fonts support styles for fractions, including slashed and stacked. The following text displays fraction styles for the Palatino Linotype font. @@ -229,6 +252,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#10](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#10)] ### Old Style Numerals + OpenType fonts support an old style numeral format. This format is useful for displaying numerals in styles that are no longer standard. The following text displays an 18th century date in standard and old style numeral formats for the Palatino Linotype font. ![Text using OpenType old style numerals](./media/opentype-font-features/opentype-old-style-numerals.gif "Text using OpenType old style numerals") @@ -242,6 +266,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#11](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#11)] ### Proportional and Tabular Figures + OpenType fonts support a proportional and tabular figure feature to control the alignment of widths when using numerals. Proportional figures treat each numeral as having a different width—"1" is narrower than "5". Tabular figures are treated as equal-width numerals so that they align vertically, which increases the readability of financial type information. The following text displays two proportional figures in the first column using the Miramonte font. Note the difference in width between the numerals "5" and "1". The second column shows the same two numeric values with the widths adjusted by using the tabular figure feature. @@ -253,6 +278,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#OpenTypeFontSnippet19](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/Window1.xaml#opentypefontsnippet19)] ### Slashed Zero + OpenType fonts support a slashed zero numeral format to emphasize the difference between the letter "O" and the numeral "0". The slashed zero numeral is often used for identifiers in financial and business information. The following text displays a sample order identifier using the Miramonte font. The first line uses standard numerals. The second line used slashed zero numerals to provide better contrast with the uppercase "O" letter. @@ -264,7 +290,9 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-xaml[OpenTypeFontSamples#OpenTypeFontSnippet15](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontSamples/CS/PageOne.xaml#opentypefontsnippet15)] + ## Typography Class + The object exposes the set of features that an OpenType font supports. By setting the properties of in markup, you can easily author documents that take advantage of OpenType features. The following text displays standard capital letters for the Pescadero font, followed by the letters styled as "SmallCaps" and "AllSmallCaps". In this case, the same font size is used for all three words. @@ -281,6 +309,7 @@ For details of the OpenType font format, see the [OpenType specification](https: [!code-vb[TypographyCodeSnippets#TypographyCodeSnippet1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/TypographyCodeSnippets/visualbasic/page1.xaml.vb#typographycodesnippet1)] ### Typography Class Properties + The following table lists the properties, values, and default settings of the object. |Property|Value(s)|Default Value| @@ -332,7 +361,7 @@ For details of the OpenType font format, see the [OpenType specification](https: ## See also - -- [OpenType specification](https://docs.microsoft.com/typography/opentype/spec/) +- [OpenType specification](/typography/opentype/spec/) - [Typography in WPF](typography-in-wpf.md) - [Sample OpenType Font Pack](sample-opentype-font-pack.md) - [Packaging Fonts with Applications](packaging-fonts-with-applications.md) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/optimizing-performance-object-behavior.md b/dotnet-desktop-guide/framework/wpf/advanced/optimizing-performance-object-behavior.md index 75d7aa64c0..5acbcc3d49 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/optimizing-performance-object-behavior.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/optimizing-performance-object-behavior.md @@ -13,39 +13,51 @@ helpviewer_keywords: ms.assetid: 73aa2f47-1d73-439a-be1f-78dc4ba2b5bd --- # Optimizing Performance: Object Behavior + Understanding the intrinsic behavior of [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] objects will help you make the right tradeoffs between functionality and performance. + ## Not Removing Event Handlers on Objects may Keep Objects Alive + The delegate that an object passes to its event is effectively a reference to that object. Therefore, event handlers can keep objects alive longer than expected. When performing clean up of an object that has registered to listen to an object's event, it is essential to remove that delegate before releasing the object. Keeping unneeded objects alive increases the application's memory usage. This is especially true when the object is the root of a logical tree or a visual tree. [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] introduces a weak event listener pattern for events that can be useful in situations where the object lifetime relationships between source and listener are difficult to keep track of. Some existing [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] events use this pattern. If you are implementing objects with custom events, this pattern may be of use to you. For details, see [Weak Event Patterns](weak-event-patterns.md). - There are several tools, such as the CLR Profiler and the Working Set Viewer, that can provides information on the memory usage of a specified process. The CLR Profiler includes a number of very useful views of the allocation profile, including a histogram of allocated types, allocation and call graphs, a time line showing garbage collections of various generations and the resulting state of the managed heap after those collections, and a call tree showing per-method allocations and assembly loads. For more information, see [Performance](https://docs.microsoft.com/previous-versions/aa497289(v=msdn.10)). + There are several tools, such as the CLR Profiler and the Working Set Viewer, that can provides information on the memory usage of a specified process. The CLR Profiler includes a number of very useful views of the allocation profile, including a histogram of allocated types, allocation and call graphs, a time line showing garbage collections of various generations and the resulting state of the managed heap after those collections, and a call tree showing per-method allocations and assembly loads. For more information, see [Performance](/previous-versions/aa497289(v=msdn.10)). + ## Dependency Properties and Objects + In general, accessing a dependency property of a is not slower than accessing a CLR property. While there is a small performance overhead for setting a property value, getting a value is as fast as getting the value from a CLR property. Offsetting the small performance overhead is the fact that dependency properties support robust features, such as data binding, animation, inheritance, and styling. For more information, see [Dependency Properties Overview](dependency-properties-overview.md). ### DependencyProperty Optimizations + You should define dependency properties in your application very carefully. If your affects only render type metadata options, rather than other metadata options such as , you should mark it as such by overriding its metadata. For more information about overriding or obtaining property metadata, see [Dependency Property Metadata](dependency-property-metadata.md). It may be more efficient to have a property change handler invalidate the measure, arrange, and render passes manually if not all property changes actually affect measure, arrange, and render. For instance, you might decide to re-render a background only when a value is greater than a set limit. In this case, your property change handler would only invalidate render when the value exceeds the set limit. ### Making a DependencyProperty Inheritable is Not Free + By default, registered dependency properties are non-inheritable. However, you can explicitly make any property inheritable. While this is a useful feature, converting a property to be inheritable impacts performance by increasing the length of time for property invalidation. ### Use RegisterClassHandler Carefully + While calling allows you to save your instance state, it is important to be aware that the handler is called on every instance, which can cause performance problems. Only use when your application requires that you save your instance state. ### Set the Default Value for a DependencyProperty during Registration + When creating a that requires a default value, set the value using the default metadata passed as a parameter to the method of the . Use this technique rather than setting the property value in a constructor or on each instance of an element. ### Set the PropertyMetadata Value using Register + When creating a , you have the option of setting the using either the or methods. Although your object could have a static constructor to call , this is not the optimal solution and will impact performance. For best performance, set the during the call to . + ## Freezable Objects + A is a special type of object that has two states: unfrozen and frozen. Freezing objects whenever possible improves the performance of your application and reduces its working set. For more information, see [Freezable Objects Overview](freezable-objects-overview.md). Each has a event that is raised whenever it changes. However, change notifications are costly in terms of application performance. @@ -70,6 +82,7 @@ Understanding the intrinsic behavior of [!INCLUDE[TLA2#tla_winclient](../../../i [!code-vb[Performance#PerformanceSnippet3](~/samples/snippets/visualbasic/VS_Snippets_Wpf/Performance/visualbasic/window1.xaml.vb#performancesnippet3)] ### Changed Handlers on Unfrozen Freezables may Keep Objects Alive + The delegate that an object passes to a object's event is effectively a reference to that object. Therefore, event handlers can keep objects alive longer than expected. When performing clean up of an object that has registered to listen to a object's event, it is essential to remove that delegate before releasing the object. [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] also hooks up events internally. For example, all dependency properties which take as a value will listen to events automatically. The property, which takes a , illustrates this concept. @@ -90,7 +103,9 @@ Understanding the intrinsic behavior of [!INCLUDE[TLA2#tla_winclient](../../../i [!code-vb[Performance#PerformanceSnippet6](~/samples/snippets/visualbasic/VS_Snippets_Wpf/Performance/visualbasic/window1.xaml.vb#performancesnippet6)] + ## User Interface Virtualization + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] also provides a variation of the element that automatically "virtualizes" data-bound child content. In this context, the word virtualize refers to a technique by which a subset of objects are generated from a larger number of data items based upon which items are visible on-screen. It is intensive, both in terms of memory and processor, to generate a large number of UI elements when only a few may be on the screen at a given time. (through functionality provided by ) calculates visible items and works with the from an (such as or ) to only create elements for visible items. As a performance optimization, visual objects for these items are only generated or kept alive if they are visible on the screen. When they are no longer in the viewable area of the control, the visual objects may be removed. This is not to be confused with data virtualization, where data objects are not all present in the local collection- rather streamed in as needed. diff --git a/dotnet-desktop-guide/framework/wpf/advanced/packaging-fonts-with-applications.md b/dotnet-desktop-guide/framework/wpf/advanced/packaging-fonts-with-applications.md index aafe67dfd1..5ff1ff5b38 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/packaging-fonts-with-applications.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/packaging-fonts-with-applications.md @@ -13,21 +13,26 @@ helpviewer_keywords: ms.assetid: db15ee48-4d24-49f5-8b9d-a64460865286 --- # Packaging Fonts with Applications + This topic provides an overview of how to package fonts with your [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] application. > [!NOTE] > As with most types of software, font files are licensed, rather than sold. Licenses that govern the use of fonts vary from vendor to vendor but in general most licenses, including those covering the fonts Microsoft supplies with applications and Windows, do not allow the fonts to be embedded within applications or otherwise redistributed. Therefore, as a developer it is your responsibility to ensure that you have the required license rights for any font you embed within an application or otherwise redistribute. + ## Introduction to Packaging Fonts + You can easily package fonts as resources within your [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications to display user interface text and other types of text based content. The fonts can be separate from or embedded within the application's assembly files. You can also create a resource-only font library, which your application can reference. OpenType and TrueType® fonts contain a type flag, fsType, that indicates font embedding licensing rights for the font. However, this type flag only refers to embedded fonts stored in a document–it does not refer to fonts embedded in an application. You can retrieve the font embedding rights for a font by creating a object and referencing its property. Refer to the "OS/2 and Windows Metrics" section of the [OpenType Specification](https://www.microsoft.com/typography/otspec/os2.htm) for more information on the fsType flag. - The [Microsoft Typography](https://docs.microsoft.com/typography/) Web site includes contact information that can help you locate a particular font vendor or find a font vendor for custom work. + The [Microsoft Typography](/typography/) Web site includes contact information that can help you locate a particular font vendor or find a font vendor for custom work. + ## Adding Fonts as Content Items + You can add fonts to your application as project content items that are separate from the application's assembly files. This means that content items are not embedded as resources within an assembly. The following project file example shows how to define content items. ```xml @@ -60,7 +65,9 @@ This topic provides an overview of how to package fonts with your [!INCLUDE[TLA# [!code-xaml[FontSnippets#FontPackageSnippet8](~/samples/snippets/csharp/VS_Snippets_Wpf/FontSnippets/CSharp/FontPackageSnippets.xaml#fontpackagesnippet8)] + ## Adding Fonts as Resource Items + You can add fonts to your application as project resource items that are embedded within the application's assembly files. Using a separate subdirectory for resources helps to organize the application's project files. The following project file example shows how to define fonts as resource items in a separate subdirectory. ```xml @@ -83,6 +90,7 @@ This topic provides an overview of how to package fonts with your [!INCLUDE[TLA# [!code-xaml[FontSnippets#FontPackageSnippet1](~/samples/snippets/csharp/VS_Snippets_Wpf/FontSnippets/CSharp/FontPackageSnippets.xaml#fontpackagesnippet1)] ### Referencing Font Resource Items from Code + In order to reference font resource items from code, you must supply a two-part font resource reference: the base uniform resource identifier (URI); and the font location reference. These values are used as the parameters for the method. The following code example shows how to reference the application's font resources in the project subdirectory called `resources`. [!code-csharp[FontSnippets#FontPackageSnippet2](~/samples/snippets/csharp/VS_Snippets_Wpf/FontSnippets/CSharp/FontPackageSnippets.xaml.cs#fontpackagesnippet2)] @@ -94,6 +102,7 @@ This topic provides an overview of how to package fonts with your [!INCLUDE[TLA# [!code-vb[FontSnippets#FontPackageSnippet5](~/samples/snippets/visualbasic/VS_Snippets_Wpf/FontSnippets/visualbasic/fontpackagesnippets.xaml.vb#fontpackagesnippet5)] ### Referencing Fonts from the Same Application Subdirectory + You can place both application content and resource files within the same user-defined subdirectory of your application project. The following project file example shows a content page and font resources defined in the same subdirectory. ```xml @@ -114,6 +123,7 @@ This topic provides an overview of how to package fonts with your [!INCLUDE[TLA# [!code-vb[FontSnippets#FontPackageSnippet4](~/samples/snippets/visualbasic/VS_Snippets_Wpf/FontSnippets/visualbasic/pages/homepage.xaml.vb#fontpackagesnippet4)] ### Enumerating Fonts in an Application + To enumerate fonts as resource items in your application, use either the or method. The following example shows how to use the method to return the collection of objects from the application font location. In this case, the application contains a subdirectory named "resources". [!code-csharp[FontSnippets#FontsSnippet3](~/samples/snippets/csharp/VS_Snippets_Wpf/FontSnippets/CSharp/FontFamilySnippets.xaml.cs#fontssnippet3)] @@ -125,7 +135,9 @@ This topic provides an overview of how to package fonts with your [!INCLUDE[TLA# [!code-vb[FontSnippets#FontsSnippet7](~/samples/snippets/visualbasic/VS_Snippets_Wpf/FontSnippets/visualbasic/fontfamilysnippets.xaml.vb#fontssnippet7)] + ## Creating a Font Resource Library + You can create a resource-only library that contains only fonts—no code is part of this type of library project. Creating a resource-only library is a common technique for decoupling resources from the application code that uses them. This also allows the library assembly to be included with multiple application projects. The following project file example shows the key portions of a resource-only library project. ```xml @@ -142,6 +154,7 @@ This topic provides an overview of how to package fonts with your [!INCLUDE[TLA# ``` ### Referencing a Font in a Resource Library + To reference a font in a resource library from your application, you must prefix the font reference with the name of the library assembly. In this case, the font resource assembly is "FontLibrary". To separate the assembly name from the reference within the assembly, use a ';' character. Adding the "Component" keyword followed by the reference to the font name completes the full reference to the font library's resource. The following code example shows how to reference a font in a resource library assembly. [!code-xaml[OpenTypeFontsSample#OpenTypeFontsSample1](~/samples/snippets/csharp/VS_Snippets_Wpf/OpenTypeFontsSample/CS/Kootenay.xaml#opentypefontssample1)] @@ -150,7 +163,9 @@ This topic provides an overview of how to package fonts with your [!INCLUDE[TLA# > This SDK contains a set of sample OpenType fonts that you can use with [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications. The fonts are defined in a resource-only library. For more information, see [Sample OpenType Font Pack](sample-opentype-font-pack.md). + ## Limitations on Font Usage + The following list describes several limitations on the packaging and use of fonts in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications: - **Font embedding permission bits:** [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications do not check or enforce any font embedding permission bits. See the [Introduction_to_Packing Fonts](#introduction_to_packaging_fonts) section for more information. @@ -169,7 +184,7 @@ This topic provides an overview of how to package fonts with your [!INCLUDE[TLA# - - -- [Microsoft Typography: Links, News, and Contacts](https://docs.microsoft.com/typography/) +- [Microsoft Typography: Links, News, and Contacts](/typography/) - [OpenType Specification](https://www.microsoft.com/typography/otspec/) - [OpenType Font Features](opentype-font-features.md) - [Sample OpenType Font Pack](sample-opentype-font-pack.md) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/the-ink-object-model-windows-forms-and-com-versus-wpf.md b/dotnet-desktop-guide/framework/wpf/advanced/the-ink-object-model-windows-forms-and-com-versus-wpf.md index 03ce298e54..4ea5850aa6 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/the-ink-object-model-windows-forms-and-com-versus-wpf.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/the-ink-object-model-windows-forms-and-com-versus-wpf.md @@ -19,7 +19,8 @@ ms.assetid: 577835be-b145-4226-8570-1d309e9b3901 There are essentially three platforms that support digital ink: the Tablet PC Windows Forms platform, the Tablet PC COM platform, and the Windows Presentation Foundation (WPF) platform. The Windows Forms and COM platforms share a similar object model, but the object model for the WPF platform is substantially different. This topic discusses the differences at a high-level so that developers that have worked with one object model can better understand the other. ## Enabling Ink in an Application - All three platforms ship objects and controls that enable an application to receive input from a tablet pen. The Windows Forms and COM platforms ship with [Microsoft.Ink.InkPicture](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583740(v=vs.90)), [Microsoft.Ink.InkEdit](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552265(v=vs.90)), [Microsoft.Ink.InkOverlay](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)) and [Microsoft.Ink.InkCollector](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) classes. [Microsoft.Ink.InkPicture](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583740(v=vs.90)) and [Microsoft.Ink.InkEdit](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552265(v=vs.90)) are controls that you can add to an application to collect ink. The [Microsoft.Ink.InkOverlay](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)) and [Microsoft.Ink.InkCollector](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) can be attached to an existing window to ink-enable windows and custom controls. + + All three platforms ship objects and controls that enable an application to receive input from a tablet pen. The Windows Forms and COM platforms ship with [Microsoft.Ink.InkPicture](/previous-versions/dotnet/netframework-3.5/ms583740(v=vs.90)), [Microsoft.Ink.InkEdit](/previous-versions/dotnet/netframework-3.5/ms552265(v=vs.90)), [Microsoft.Ink.InkOverlay](/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)) and [Microsoft.Ink.InkCollector](/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) classes. [Microsoft.Ink.InkPicture](/previous-versions/dotnet/netframework-3.5/ms583740(v=vs.90)) and [Microsoft.Ink.InkEdit](/previous-versions/dotnet/netframework-3.5/ms552265(v=vs.90)) are controls that you can add to an application to collect ink. The [Microsoft.Ink.InkOverlay](/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)) and [Microsoft.Ink.InkCollector](/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) can be attached to an existing window to ink-enable windows and custom controls. The WPF platform includes the control. You can add an to your application and begin collecting ink immediately. With the , the user can copy, select, and resize ink. You can add other controls to the , and the user can handwrite over those controls, too. You can create an ink-enabled custom control by adding an to it and collecting its stylus points. @@ -31,11 +32,12 @@ There are essentially three platforms that support digital ink: the Tablet PC Wi |Enable ink on a custom control|See [Creating an Ink Input Control](creating-an-ink-input-control.md).|See [Ink Clipboard Sample](/windows/desktop/tablet/ink-clipboard-sample).| ## Ink Data - On the Windows Forms and COM platforms, [Microsoft.Ink.InkCollector](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)), [Microsoft.Ink.InkOverlay](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)), [Microsoft.Ink.InkEdit](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552265(v=vs.90)), and [Microsoft.Ink.InkPicture](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583740(v=vs.90)) each expose a [Microsoft.Ink.Ink](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object. The [Microsoft.Ink.Ink](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object contains the data for one or more [Microsoft.Ink.Stroke](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552692(v=vs.90)) objects and exposes common methods and properties to manage and manipulate those strokes. The [Microsoft.Ink.Ink](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object manages the lifetime of the strokes it contains; the [Microsoft.Ink.Ink](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object creates and deletes the strokes that it owns. Each [Microsoft.Ink.Stroke](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552692(v=vs.90)) has an identifier that is unique within its parent [Microsoft.Ink.Ink](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object. + + On the Windows Forms and COM platforms, [Microsoft.Ink.InkCollector](/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)), [Microsoft.Ink.InkOverlay](/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)), [Microsoft.Ink.InkEdit](/previous-versions/dotnet/netframework-3.5/ms552265(v=vs.90)), and [Microsoft.Ink.InkPicture](/previous-versions/dotnet/netframework-3.5/ms583740(v=vs.90)) each expose a [Microsoft.Ink.Ink](/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object. The [Microsoft.Ink.Ink](/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object contains the data for one or more [Microsoft.Ink.Stroke](/previous-versions/dotnet/netframework-3.5/ms552692(v=vs.90)) objects and exposes common methods and properties to manage and manipulate those strokes. The [Microsoft.Ink.Ink](/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object manages the lifetime of the strokes it contains; the [Microsoft.Ink.Ink](/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object creates and deletes the strokes that it owns. Each [Microsoft.Ink.Stroke](/previous-versions/dotnet/netframework-3.5/ms552692(v=vs.90)) has an identifier that is unique within its parent [Microsoft.Ink.Ink](/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object. - On the WPF platform, the class owns and manages its own lifetime. A group of objects can be collected together in a , which provides methods for common ink data management operations such as hit testing, erasing, transforming, and serializing the ink. A can belong to zero, one, or more objects at any give time. Instead of having a [Microsoft.Ink.Ink](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object, the and contain a . + On the WPF platform, the class owns and manages its own lifetime. A group of objects can be collected together in a , which provides methods for common ink data management operations such as hit testing, erasing, transforming, and serializing the ink. A can belong to zero, one, or more objects at any give time. Instead of having a [Microsoft.Ink.Ink](/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object, the and contain a . - The following pair of illustrations compares the ink data object models. On the Windows Forms and COM platforms, the [Microsoft.Ink.Ink](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object constrains the lifetime of the [Microsoft.Ink.Stroke](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552692(v=vs.90)) objects, and the stylus packets belong to the individual strokes. Two or more strokes can reference the same [Microsoft.Ink.DrawingAttributes](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583636(v=vs.90)) object, as shown in the following illustration. + The following pair of illustrations compares the ink data object models. On the Windows Forms and COM platforms, the [Microsoft.Ink.Ink](/previous-versions/dotnet/netframework-3.5/ms583670(v=vs.90)) object constrains the lifetime of the [Microsoft.Ink.Stroke](/previous-versions/dotnet/netframework-3.5/ms552692(v=vs.90)) objects, and the stylus packets belong to the individual strokes. Two or more strokes can reference the same [Microsoft.Ink.DrawingAttributes](/previous-versions/dotnet/netframework-3.5/ms583636(v=vs.90)) object, as shown in the following illustration. ![Diagram of the Ink Object Model for COM/Winforms.](./media/ink-inkownsstrokes.png "Ink_InkOwnsStrokes") @@ -47,14 +49,15 @@ There are essentially three platforms that support digital ink: the Tablet PC Wi |Task|Windows Presentation Foundation|Windows Forms and COM| |----------|-------------------------------------|---------------------------| -|Save Ink||[Microsoft.Ink.Ink.Save](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms571335(v=vs.90))| -|Load Ink|Create a with the constructor.|[Microsoft.Ink.Ink.Load](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms569609(v=vs.90))| -|Hit test||[Microsoft.Ink.Ink.HitTest](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms571330(v=vs.90))| -|Copy Ink||[Microsoft.Ink.Ink.ClipboardCopy](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms571316(v=vs.90))| -|Paste Ink||[Microsoft.Ink.Ink.ClipboardPaste](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms571318(v=vs.90))| -|Access custom properties on a collection of strokes| (the properties are stored internally and accessed via , , and )|Use [Microsoft.Ink.Ink.ExtendedProperties](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms582214(v=vs.90))| +|Save Ink||[Microsoft.Ink.Ink.Save](/previous-versions/dotnet/netframework-3.5/ms571335(v=vs.90))| +|Load Ink|Create a with the constructor.|[Microsoft.Ink.Ink.Load](/previous-versions/dotnet/netframework-3.5/ms569609(v=vs.90))| +|Hit test||[Microsoft.Ink.Ink.HitTest](/previous-versions/dotnet/netframework-3.5/ms571330(v=vs.90))| +|Copy Ink||[Microsoft.Ink.Ink.ClipboardCopy](/previous-versions/dotnet/netframework-3.5/ms571316(v=vs.90))| +|Paste Ink||[Microsoft.Ink.Ink.ClipboardPaste](/previous-versions/dotnet/netframework-3.5/ms571318(v=vs.90))| +|Access custom properties on a collection of strokes| (the properties are stored internally and accessed via , , and )|Use [Microsoft.Ink.Ink.ExtendedProperties](/previous-versions/dotnet/netframework-3.5/ms582214(v=vs.90))| ### Sharing ink between platforms + Although the platforms have different object models for the ink data, sharing the data between the platforms is very easy. The following examples save ink from a Windows Forms application and load the ink into a Windows Presentation Foundation application. [!code-csharp[WinFormWPFInk#UsingWinforms](~/samples/snippets/csharp/VS_Snippets_Wpf/WinformWPFInk/CSharp/Program.cs#usingwinforms)] @@ -78,9 +81,10 @@ There are essentially three platforms that support digital ink: the Tablet PC Wi [!code-vb[WinFormWPFInk#UsingWinforms](~/samples/snippets/visualbasic/VS_Snippets_Wpf/WinformWPFInk/VisualBasic/Module1.vb#usingwinforms)] [!code-csharp[WinFormWPFInk#LoadWinforms](~/samples/snippets/csharp/VS_Snippets_Wpf/WinformWPFInk/CSharp/Program.cs#loadwinforms)] [!code-vb[WinFormWPFInk#LoadWinforms](~/samples/snippets/visualbasic/VS_Snippets_Wpf/WinformWPFInk/VisualBasic/Module1.vb#loadwinforms)] + ## Events from the Tablet Pen - The [Microsoft.Ink.InkOverlay](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)), [Microsoft.Ink.InkCollector](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)), and [Microsoft.Ink.InkPicture](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583740(v=vs.90)) on the Windows Forms and COM platforms receive events when the user inputs pen data. The [Microsoft.Ink.InkOverlay](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)) or [Microsoft.Ink.InkCollector](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) is attached to a window or a control, and can subscribe to the events raised by the tablet input data. The thread on which these events occurs depends on whether the events are raised with a pen, a mouse, or programmatically. For more information about threading in relation to these events, see [General Threading Considerations](/windows/desktop/tablet/general-threading-considerations) and [Threads on Which an Event Can Fire](/windows/desktop/tablet/threads-on-which-an-event-can-fire). + The [Microsoft.Ink.InkOverlay](/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)), [Microsoft.Ink.InkCollector](/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)), and [Microsoft.Ink.InkPicture](/previous-versions/dotnet/netframework-3.5/ms583740(v=vs.90)) on the Windows Forms and COM platforms receive events when the user inputs pen data. The [Microsoft.Ink.InkOverlay](/previous-versions/dotnet/netframework-3.5/ms552322(v=vs.90)) or [Microsoft.Ink.InkCollector](/previous-versions/dotnet/netframework-3.5/ms583683(v=vs.90)) is attached to a window or a control, and can subscribe to the events raised by the tablet input data. The thread on which these events occurs depends on whether the events are raised with a pen, a mouse, or programmatically. For more information about threading in relation to these events, see [General Threading Considerations](/windows/desktop/tablet/general-threading-considerations) and [Threads on Which an Event Can Fire](/windows/desktop/tablet/threads-on-which-an-event-can-fire). On the Windows Presentation Foundation platform, the class has events for pen input. This means that every control exposes the full set of stylus events. The stylus events have tunneling/bubbling event pairs and always occur on the application thread. For more information, see [Routed Events Overview](routed-events-overview.md). @@ -89,9 +93,10 @@ There are essentially three platforms that support digital ink: the Tablet PC Wi ![Diagram of the Stylus events in WPF vs Winforms.](./media/ink-stylusevents.png "Ink_StylusEvents") ## Pen Data - All three platforms provide you with ways to intercept and manipulate the data that comes in from a tablet pen. On the Windows Forms and COM Platforms, this is achieved by creating a [Microsoft.StylusInput.RealTimeStylus](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms585724(v=vs.90)), attaching a window or control to it, and creating a class that implements the [Microsoft.StylusInput.IStylusSyncPlugin](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms575201(v=vs.90)) or [Microsoft.StylusInput.IStylusAsyncPlugin](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms575194(v=vs.90)) interface. The custom plug-in is then added to the plug-in collection of the [Microsoft.StylusInput.RealTimeStylus](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms585724(v=vs.90)). For more information about this object model, see [Architecture of the StylusInput APIs](/windows/desktop/tablet/architecture-of-the-stylusinput-apis). + + All three platforms provide you with ways to intercept and manipulate the data that comes in from a tablet pen. On the Windows Forms and COM Platforms, this is achieved by creating a [Microsoft.StylusInput.RealTimeStylus](/previous-versions/dotnet/netframework-3.5/ms585724(v=vs.90)), attaching a window or control to it, and creating a class that implements the [Microsoft.StylusInput.IStylusSyncPlugin](/previous-versions/dotnet/netframework-3.5/ms575201(v=vs.90)) or [Microsoft.StylusInput.IStylusAsyncPlugin](/previous-versions/dotnet/netframework-3.5/ms575194(v=vs.90)) interface. The custom plug-in is then added to the plug-in collection of the [Microsoft.StylusInput.RealTimeStylus](/previous-versions/dotnet/netframework-3.5/ms585724(v=vs.90)). For more information about this object model, see [Architecture of the StylusInput APIs](/windows/desktop/tablet/architecture-of-the-stylusinput-apis). - On the WPF platform, the class exposes a collection of plug-ins, similar in design to the [Microsoft.StylusInput.RealTimeStylus](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms585724(v=vs.90)). To intercept pen data, create a class that inherits from and add the object to the collection of the . For more information about this interaction, see [Intercepting Input from the Stylus](intercepting-input-from-the-stylus.md). + On the WPF platform, the class exposes a collection of plug-ins, similar in design to the [Microsoft.StylusInput.RealTimeStylus](/previous-versions/dotnet/netframework-3.5/ms585724(v=vs.90)). To intercept pen data, create a class that inherits from and add the object to the collection of the . For more information about this interaction, see [Intercepting Input from the Stylus](intercepting-input-from-the-stylus.md). On all platforms, a thread pool receives the ink data via stylus events and sends it to the application thread. For more information about threading on the COM and Windows Platforms, see [Threading Considerations for the StylusInput APIs](/windows/desktop/tablet/threading-considerations-for-the-stylusinput-apis). For more information about threading on the Windows Presentation Software, see [The Ink Threading Model](the-ink-threading-model.md). diff --git a/dotnet-desktop-guide/framework/wpf/advanced/trees-in-wpf.md b/dotnet-desktop-guide/framework/wpf/advanced/trees-in-wpf.md index 9062ff3a1f..d6845a4c5e 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/trees-in-wpf.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/trees-in-wpf.md @@ -8,10 +8,13 @@ helpviewer_keywords: ms.assetid: e83f25e5-d66b-4fc7-92d2-50130c9a6649 --- # Trees in WPF + In many technologies, elements and components are organized in a tree structure where developers directly manipulate the object nodes in the tree to affect the rendering or behavior of an application. [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] also uses several tree structure metaphors to define relationships between program elements. For the most part WPF developers can create an application in code or define portions of the application in XAML while thinking conceptually about the object tree metaphor, but will be calling specific API or using specific markup to do so rather than some general object tree manipulation API such as you might use in XML DOM. WPF exposes two helper classes that provide a tree metaphor view, and . The terms visual tree and logical tree are also used in the WPF documentation because these same trees are useful for understanding the behavior of certain key WPF features. This topic defines what the visual tree and logical tree represent, discusses how such trees relate to an overall object tree concept, and introduces and s. + ## Trees in WPF + The most complete tree structure in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] is the object tree. If you define an application page in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] and then load the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)], the tree structure is created based on the nesting relationships of the elements in the markup. If you define an application or a portion of the application in code, then the tree structure is created based on how you assign property values for properties that implement the content model for a given object. In [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)], there are two ways that the complete object tree is conceptualized and can be reported to its public API: as the logical tree and as the visual tree. The distinctions between logical tree and visual tree are not always necessarily important, but they can occasionally cause issues with certain [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] subsystems and affect choices you make in markup or code. Even though you do not always manipulate either the logical tree or the visual tree directly, understanding the concepts of how the trees interact is useful for understanding WPF as a technology. Thinking of WPF as a tree metaphor of some kind is also crucial to understanding how property inheritance and event routing work in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]. @@ -20,8 +23,10 @@ In many technologies, elements and components are organized in a tree structure > Because the object tree is more of a concept than an actual API, another way to think of the concept is as an object graph. In practice, there are relationships between objects at run time where the tree metaphor will break down. Nevertheless, particularly with XAML-defined UI, the tree metaphor is relevant enough that most WPF documentation will use the term object tree when referencing this general concept. + ## The Logical Tree - In [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)], you add content to UI elements by setting properties of the objects that back those elements. For example, you add items to a control by manipulating its property. By doing this, you are placing items into the that is the property value. Similarly, to add objects to a , you manipulate its property value. Here, you are adding objects to the . For a code example, see [How to: Add an Element Dynamically](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms752374(v=vs.100)). + + In [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)], you add content to UI elements by setting properties of the objects that back those elements. For example, you add items to a control by manipulating its property. By doing this, you are placing items into the that is the property value. Similarly, to add objects to a , you manipulate its property value. Here, you are adding objects to the . For a code example, see [How to: Add an Element Dynamically](/previous-versions/dotnet/netframework-4.0/ms752374(v=vs.100)). In [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)], when you place list items in a or controls or other UI elements in a , you also use the and properties, either explicitly or implicitly, as in the following example. @@ -34,33 +39,47 @@ In many technologies, elements and components are organized in a tree structure For more information about how [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] syntax maps to the created object graph, and implicit syntax in XAML, see [XAML Syntax In Detail](xaml-syntax-in-detail.md) or [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml). + ### The Purpose of the Logical Tree + The logical tree exists so that content models can readily iterate over their possible child objects, and so that content models can be extensible. Also, the logical tree provides a framework for certain notifications, such as when all objects in the logical tree are loaded. Basically, the logical tree is an approximation of a run time object graph at the framework level, which excludes visuals, but is adequate for many querying operations against your own run time application's composition. In addition, both static and dynamic resource references are resolved by looking upwards through the logical tree for collections on the initial requesting object, and then continuing up the logical tree and checking each (or ) for another `Resources` value that contains a , possibly containing that key. The logical tree is used for resource lookup when both the logical tree and the visual tree are present. For more information on resource dictionaries and lookup, see [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define). + ### Composition of the Logical Tree + The logical tree is defined at the WPF framework-level, which means that the WPF base element that is most relevant for logical tree operations is either or . However, as you can see if you actually use the API, the logical tree sometimes contains nodes that are not either or . For instance, the logical tree reports the value of a , which is a string. + ### Overriding the Logical Tree + Advanced control authors can override the logical tree by overriding several APIs that define how a general object or content model adds or removes objects within the logical tree. For an example of how to override the logical tree, see [Override the Logical Tree](how-to-override-the-logical-tree.md). + ### Property Value Inheritance + Property value inheritance operates through a hybrid tree. The actual metadata that contains the property that enables property inheritance is the WPF framework-level class. Therefore, both the parent that holds the original value and the child object that inherits that value must both be or , and they must both be part of some logical tree. However, for existing WPF properties that support property inheritance, property value inheritance is able to perpetuate through an intervening object that is not in the logical tree. Mainly this is relevant for having template elements use any inherited property values set either on the instance that is templated, or at still higher levels of page-level composition and therefore higher in the logical tree. In order for property value inheritance to work consistently across such a boundary, the inheriting property must be registered as an attached property, and you should follow this pattern if you intend to define a custom dependency property with property inheritance behavior. The exact tree used for property inheritance cannot be entirely anticipated by a helper class utility method, even at run time. For more information, see [Property Value Inheritance](property-value-inheritance.md). + ## The Visual Tree + In addition to the concept of the logical tree, there is also the concept of the visual tree in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]. The visual tree describes the structure of visual objects, as represented by the base class. When you write a template for a control, you are defining or redefining the visual tree that applies for that control. The visual tree is also of interest to developers who want lower-level control over drawing for performance and optimization reasons. One exposure of the visual tree as part of conventional [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] application programming is that event routes for a routed event mostly travel along the visual tree, not the logical tree. This subtlety of routed event behavior might not be immediately apparent unless you are a control author. Routing events through the visual tree enables controls that implement composition at the visual level to handle events or create event setters. + ## Trees, Content Elements, and Content Hosts + Content elements (classes that derive from ) are not part of the visual tree; they do not inherit from and do not have a visual representation. In order to appear in a UI at all, a must be hosted in a content host that is both a and a logical tree participant. Usually such an object is a . You can conceptualize that the content host is somewhat like a "browser" for the content and chooses how to display that content within the screen region that the host controls. When the content is hosted, the content can be made a participant in certain tree processes that are normally associated with the visual tree. Generally, the host class includes implementation code that adds any hosted to the event route through subnodes of the content logical tree, even though the hosted content is not part of the true visual tree. This is necessary so that a can source a routed event that routes to any element other than itself. + ## Tree Traversal + The class provides the , , and methods for logical tree traversal. In most cases, you should not have to traverse the logical tree of existing controls, because these controls almost always expose their logical child elements as a dedicated collection property that supports collection access such as `Add`, an indexer, and so on. Tree traversal is mainly a scenario that is used by control authors who choose not to derive from intended control patterns such as or where collection properties are already defined, and who intend to provide their own collection property support. The visual tree also supports a helper class for visual tree traversal, . The visual tree is not exposed as conveniently through control-specific properties, so the class is the recommended way to traverse the visual tree if that is necessary for your programming scenario. For more information, see [WPF Graphics Rendering Overview](../graphics-multimedia/wpf-graphics-rendering-overview.md). @@ -69,11 +88,15 @@ In many technologies, elements and components are organized in a tree structure > Sometimes it is necessary to examine the visual tree of an applied template. You should be careful when using this technique. Even if you are traversing a visual tree for a control where you define the template, consumers of your control can always change the template by setting the property on instances, and even the end user can influence the applied template by changing the system theme. + ## Routes for Routed Events as a "Tree" + As mentioned before, the route of any given routed event travels along a single and predetermined path of a tree that is a hybrid of the visual and logical tree representations. The event route can travel either in the up or down directions within the tree depending on whether it is a tunneling or bubbling routed event. The event route concept does not have a directly supporting helper class that could be used to "walk" the event route independently of raising an event that actually routes. There is a class that represents the route, , but the methods of that class are generally for internal use only. + ## Resource Dictionaries and Trees + Resource dictionary lookup for all `Resources` defined in a page traverses basically the logical tree. Objects that are not in the logical tree can reference keyed resources, but the resource lookup sequence begins at the point where that object is connected to the logical tree. In WPF, only logical tree nodes can have a `Resources` property that contains a , therefore there is no benefit in traversing the visual tree looking for keyed resources from a . However, resource lookup can also extend beyond the immediate logical tree. For application markup, the resource lookup can then continue onward to application-level resource dictionaries and then to theme support and system values that are referenced as static properties or keys. Themes themselves can also reference system values outside of the theme logical tree if the resource references are dynamic. For more information on resource dictionaries and the lookup logic, see [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define). diff --git a/dotnet-desktop-guide/framework/wpf/advanced/troubleshooting-hybrid-applications.md b/dotnet-desktop-guide/framework/wpf/advanced/troubleshooting-hybrid-applications.md index 4ccb7d6118..e3cad117c3 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/troubleshooting-hybrid-applications.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/troubleshooting-hybrid-applications.md @@ -11,10 +11,13 @@ helpviewer_keywords: ms.assetid: f440c23f-fa5d-4d5a-852f-ba61150e6405 --- # Troubleshooting Hybrid Applications + This topic lists some common problems that can occur when authoring hybrid applications, which use both [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] and Windows Forms technologies. + ## Overlapping Controls + Controls may not overlap as you would expect. Windows Forms uses a separate HWND for each control. [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] uses one HWND for all content on a page. This implementation difference causes unexpected overlapping behaviors. A Windows Forms control hosted in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] always appears on top of the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] content. @@ -22,33 +25,47 @@ ms.assetid: f440c23f-fa5d-4d5a-852f-ba61150e6405 [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] content hosted in an control appears at the z-order of the control. It is possible to overlap controls, but the hosted [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] content does not combine or interact. + ## Child Property + The and classes can host only a single child control or element. To host more than one control or element, you must use a container as the child content. For example, you could add Windows Forms button and check box controls to a control, and then assign the panel to a control's property. However, you cannot add the button and check box controls separately to the same control. + ## Scaling + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] and Windows Forms have different scaling models. Some [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] scaling transformations are meaningful to Windows Forms controls, but others are not. For example, scaling a Windows Forms control to 0 will work, but if you try to scale the same control back to a non-zero value, the control's size remains 0. For more information, see [Layout Considerations for the WindowsFormsHost Element](layout-considerations-for-the-windowsformshost-element.md). + ## Adapter + There may be confusion when working the and classes, because they include a hidden container. Both the and classes have a hidden container, called an *adapter*, which they use to host content. For the element, the adapter derives from the class. For the control, the adapter derives from the element. When you see references to the adapter in other interoperation topics, this container is what is being discussed. + ## Nesting + Nesting a element inside an control is not supported. Nesting an control inside a element is also not supported. + ## Focus + Focus works differently in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] and Windows Forms, which means that focus issues may occur in a hybrid application. For example, if you have focus inside a element, and you either minimize and restore the page or show a modal dialog box, focus inside the element may be lost. The element still has focus, but the control inside it may not. Data validation is also affected by focus. Validation works in a element, but it does not work as you tab out of the element, or between two different elements. + ## Property Mapping + Some property mappings require extensive interpretation to bridge dissimilar implementations between the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] and Windows Forms technologies. Property mappings enable your code to react to changes in fonts, colors, and other properties. In general, property mappings work by listening for either *Property*Changed events or On*Property*Changed calls, and setting appropriate properties on either the child control or its adapter. For more information, see [Windows Forms and WPF Property Mapping](windows-forms-and-wpf-property-mapping.md). + ## Layout-related Properties on Hosted Content + When the or property is assigned, several layout-related properties on the hosted content are set automatically. Changing these content properties can cause unexpected layout behaviors. Your hosted content is docked to fill the and parent. To enable this fill behavior, several properties are set when you set the child property. The following table lists which content properties are set by the and classes. @@ -61,56 +78,74 @@ ms.assetid: f440c23f-fa5d-4d5a-852f-ba61150e6405 Do not set these properties directly on the hosted content. For more information, see [Layout Considerations for the WindowsFormsHost Element](layout-considerations-for-the-windowsformshost-element.md). + ## Navigation Applications + Navigation applications may not maintain user state. The element recreates its controls when it is used in a navigation application. Recreating child controls occurs when the user navigates away from the page hosting the element and then returns to it. Any content that has been typed in by the user will be lost. + ## Message Loop Interoperation + When working with Windows Forms message loops, messages may not be processed as expected. The method is called by the constructor. This method adds a message filter to the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] message loop. This filter calls the method if a was the target of the message and translates/dispatches the message. If you show a in a Windows Forms message loop with , you cannot type anything unless you call the method. The method takes a and adds a , which reroutes key-related messages to the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] message loop. For more information, see [Windows Forms and WPF Interoperability Input Architecture](windows-forms-and-wpf-interoperability-input-architecture.md). + ## Opacity and Layering + The class does not support layering. This means that setting the property on the element has no effect, and no blending will occur with other [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] windows which have set to `true`. + ## Dispose + Not disposing classes properly can leak resources. In your hybrid applications, make sure that the and classes are disposed, or you could leak resources. Windows Forms disposes controls when its non-modal parent closes. [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] disposes elements when your application shuts down. It is possible to show a element in a in a Windows Forms message loop. In this case, your code may not receive notification that your application is shutting down. + ## Enabling Visual Styles + Microsoft Windows XP visual styles on a Windows Forms control may not be enabled. The method is called in the template for a Windows Forms application. Although this method is not called by default, if you use Visual Studio to create a project, you will get Microsoft Windows XP visual styles for controls, if version 6.0 of Comctl32.dll is available. You must call the method before handles are created on the thread. For more information, see [How to: Enable Visual Styles in a Hybrid Application](how-to-enable-visual-styles-in-a-hybrid-application.md). + ## Licensed Controls + Licensed Windows Forms controls that display licensing information in a message box to the user might cause unexpected behavior for a hybrid application. Some licensed controls show a dialog box in response to handle creation. For example, a licensed control might inform the user that a license is required, or that the user has three remaining trial uses of the control. The element derives from the class, and the child control’s handle is created inside the method. The class does not allow messages to be processed in the method, but displaying a dialog box causes messages to be sent. To enable this licensing scenario, call the method on the control before assigning it as the element's child. + ## WPF Designer + You can design your WPF content by using the WPF Designer for Visual Studio. The following sections list some common problems that can occur when authoring hybrid applications with the WPF Designer. ### BackColorTransparent is ignored at design time + The property might not work as expected at design time. If a WPF control is not on a visible parent, the WPF runtime ignores the value. The reason that might be ignored is because object is created in a separate . However, when you run the application, does work as expected. ### Design-time Error List appears when the obj folder is deleted + If the obj folder is deleted, the Design-time Error List appears. When you design using , the Windows Forms Designer uses generated files in the Debug or Release folder within your project's obj folder. If you delete these files, the Design-time Error List appears. To fix this problem, rebuild your project. For more information, see [Design-Time Errors in the Windows Forms Designer](/dotnet/framework/winforms/controls/design-time-errors-in-the-windows-forms-designer). + ## ElementHost and IME + WPF controls hosted in an currently do not support the property. Changes to will be ignored by the hosted controls. ## See also - - -- [Interoperability in the WPF Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/bb628658(v=vs.100)) +- [Interoperability in the WPF Designer](/previous-versions/visualstudio/visual-studio-2010/bb628658(v=vs.100)) - [Windows Forms and WPF Interoperability Input Architecture](windows-forms-and-wpf-interoperability-input-architecture.md) - [How to: Enable Visual Styles in a Hybrid Application](how-to-enable-visual-styles-in-a-hybrid-application.md) - [Layout Considerations for the WindowsFormsHost Element](layout-considerations-for-the-windowsformshost-element.md) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/typography-in-wpf.md b/dotnet-desktop-guide/framework/wpf/advanced/typography-in-wpf.md index 0bf4de7792..a7641b514e 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/typography-in-wpf.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/typography-in-wpf.md @@ -6,10 +6,13 @@ helpviewer_keywords: ms.assetid: 06cbf17b-6eff-4fe5-949d-2dd533e4e1f4 --- # Typography in WPF + This topic introduces the major typographic features of [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]. These features include improved quality and performance of text rendering, OpenType typography support, enhanced international text, enhanced font support, and new text application programming interfaces (APIs). + ## Improved Quality and Performance of Text + Text in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] is rendered using Microsoft ClearType, which enhances the clarity and readability of text. ClearType is a software technology developed by Microsoft that improves the readability of text on existing LCDs (Liquid Crystal Displays), such as laptop screens, Pocket PC screens and flat panel monitors. ClearType uses sub-pixel rendering which allows text to be displayed with a greater fidelity to its true shape by aligning characters on a fractional part of a pixel. The extra resolution increases the sharpness of the tiny details in text display, making it much easier to read over long durations. Another improvement of ClearType in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] is y-direction anti-aliasing, which smoothes the tops and bottoms of shallow curves in text characters. For more details on ClearType features, see [ClearType Overview](cleartype-overview.md). ![Text with ClearType y-direction anti-aliasing](./media/typography-in-wpf/text-y-direction-antialiasing.gif) @@ -22,7 +25,9 @@ Text with ClearType y-direction antialiasing In addition, animated text, whether by character or glyph, takes full advantage of the graphics hardware capability enabled by [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]. This results in smooth text animation. + ## Rich Typography + The OpenType font format is an extension of the TrueType® font format. The OpenType font format was developed jointly by Microsoft and Adobe, and provides a rich assortment of advanced typographic features. The object exposes many of the advanced features of OpenType fonts, such as stylistic alternates and swashes. The Windows SDK provides a set of sample OpenType fonts that are designed with rich features, such as the Pericles and Pescadero fonts. For more information, see [Sample OpenType Font Pack](sample-opentype-font-pack.md). The Pericles OpenType font contains additional glyphs that provide stylistic alternates to the standard set of glyphs. The following text displays stylistic alternate glyphs. @@ -36,7 +41,9 @@ Text with ClearType y-direction antialiasing For more details on OpenType features, see [OpenType Font Features](opentype-font-features.md). + ## Enhanced International Text Support + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] provides enhanced international text support by providing the following features: - Automatic line-spacing in all writing systems, using adaptive measurement. @@ -46,7 +53,9 @@ Text with ClearType y-direction antialiasing - Language-guided line breaking, hyphenation, and justification. + ## Enhanced Font Support + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] provides enhanced font support by providing the following features: - Unicode for all text. Font behavior and selection no longer require charset or codepage. @@ -64,7 +73,9 @@ Text with ClearType y-direction antialiasing - Composite fonts embedded in a document, thereby providing document portability. For more information, see the remarks in the class. + ## New Text Application Programming Interfaces (APIs) + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] provides several text APIs for developers to use when including text in their applications. These APIs are grouped into three categories: - **Layout and user interface**. The common text controls for the graphical user interface (GUI). @@ -74,9 +85,11 @@ Text with ClearType y-direction antialiasing - **Advanced text formatting**. Allows you to implement a custom text engine. ### Layout and User Interface + At the highest level of functionality, the text APIs provide common [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)] controls such as , , and . These controls provide the basic [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] elements within an application, and offer an easy way to present and interact with text. Controls such as and enable more advanced or specialized text-handling. And classes such as , , and enable useful text manipulation. These [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] controls provide properties such as , , and , which enable you to control the font that is used to render the text. #### Using Bitmap Effects, Transforms, and Text Effects + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] allows you to create visually interesting uses of text by uses features such as bitmap effects, transforms, and text effects. The following example shows a typical type of a drop shadow effect applied to text. ![Text shadow with Softness = 0.25](./media/typography-in-wpf/drop-shadow-text-effect.jpg) @@ -106,6 +119,7 @@ Text with ClearType y-direction antialiasing ![Screenshot of text effect rotating text](./media/typography-in-wpf/rotating-text-effect.jpg) #### Using Flow Documents + In addition to the common [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] controls, [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] offers a layout control for text presentation—the element. The element, in conjunction with the element, provides a control for large amounts of text with varying layout requirements. Layout controls provide access to advanced typography through the object and font-related properties of other [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] controls. The following example shows text content hosted in a , which provides search, navigation, pagination, and content scaling support. @@ -115,6 +129,7 @@ Text with ClearType y-direction antialiasing For more information, see [Documents in WPF](documents-in-wpf.md). ### Lightweight Text Drawing + You can draw text directly to [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] objects by using the method of the object. To use this method, you create a object. This object allows you to draw multi-line text, in which each character in the text can be individually formatted. The functionality of the object contains much of the functionality of the DrawText flags in the Windows API. In addition, the object contains functionality such as ellipsis support, in which an ellipsis is displayed when text exceeds its bounds. The following example shows text that has several formats applied to it, including a linear gradient on the second and third words. ![Text displayed using FormattedText object](./media/typography-in-wpf/text-formatted-linear-gradient.jpg) @@ -134,6 +149,7 @@ Text with ClearType y-direction antialiasing For more information on the object, see [Drawing Formatted Text](drawing-formatted-text.md). ### Advanced Text Formatting + At the most advanced level of the text APIs, [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] offers you the ability to create custom text layout by using the object and other types in the namespace. The and associated classes allow you to implement custom text layout that supports your own definition of character formats, paragraph styles, line breaking rules, and other layout features for international text. There are very few cases in which you would want to override the default implementation of the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] text layout support. However, if you were creating a text editing control or application, you might require a different implementation than the default [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] implementation. Unlike a traditional text API, the interacts with a text layout client through a set of callback methods. It requires the client to provide these methods in an implementation of the class. The following diagram illustrates the text layout interaction between the client application and . @@ -151,4 +167,4 @@ Text with ClearType y-direction antialiasing - [Drawing Formatted Text](drawing-formatted-text.md) - [Advanced Text Formatting](advanced-text-formatting.md) - [Text](optimizing-performance-text.md) -- [Microsoft Typography](https://docs.microsoft.com/typography/) +- [Microsoft Typography](/typography/) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-binding-to-data-in-hybrid-applications.md b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-binding-to-data-in-hybrid-applications.md index 0f20ee40f4..f5b97cdc30 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-binding-to-data-in-hybrid-applications.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-binding-to-data-in-hybrid-applications.md @@ -123,7 +123,7 @@ With Visual Studio, you can easily add a data source to your project. This proce 1. From the **Data** menu, select **Add New Data Source**. -2. In the **Data Source Configuration Wizard**, create a connection to the Northwind database by using a dataset. For more information, see [How to: Connect to Data in a Database](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2013/fxk9yw1t(v=vs.120)). +2. In the **Data Source Configuration Wizard**, create a connection to the Northwind database by using a dataset. For more information, see [How to: Connect to Data in a Database](/previous-versions/visualstudio/visual-studio-2013/fxk9yw1t(v=vs.120)). 3. When you are prompted by the **Data Source Configuration Wizard**, save the connection string as `NorthwindConnectionString`. diff --git a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-hosting-a-3-d-wpf-composite-control-in-windows-forms.md b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-hosting-a-3-d-wpf-composite-control-in-windows-forms.md index da137f6fd2..4c9f0d7e58 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-hosting-a-3-d-wpf-composite-control-in-windows-forms.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-hosting-a-3-d-wpf-composite-control-in-windows-forms.md @@ -31,6 +31,7 @@ You need the following components to complete this walkthrough: - Visual Studio 2017 + ## Create the UserControl 1. Create a **WPF User Control Library** project named `HostingWpfUserControlInWf`. @@ -44,6 +45,7 @@ You need the following components to complete this walkthrough: This code defines a that contains two child controls. The first child control is a control; the second is a control that displays a 3D cone. + ## Create the host project 1. Add a **Windows Forms App (.NET Framework)** project named `WpfUserControlHost` to the solution. @@ -63,6 +65,7 @@ You need the following components to complete this walkthrough: 5. In Solution Explorer, set the `WpfUserControlHost` project to be the startup project. + ## Host the UserControl 1. In the Windows Forms Designer, open Form1. @@ -87,4 +90,4 @@ You need the following components to complete this walkthrough: - [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio) - [Walkthrough: Hosting a WPF Composite Control in Windows Forms](walkthrough-hosting-a-wpf-composite-control-in-windows-forms.md) - [Walkthrough: Hosting a Windows Forms Composite Control in WPF](walkthrough-hosting-a-windows-forms-composite-control-in-wpf.md) -- [Hosting a WPF Composite Control in Windows Forms Sample](https://go.microsoft.com/fwlink/?LinkID=160001) +- [Hosting a WPF Composite Control in Windows Forms Sample](https://github.com/microsoft/WPF-Samples/tree/master/Migration%20and%20Interoperability/WindowsFormsHostingWpfControl) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-composite-control-in-wpf.md b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-composite-control-in-wpf.md index b6b2348abd..a7ed4657a6 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-composite-control-in-wpf.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-composite-control-in-wpf.md @@ -11,6 +11,7 @@ helpviewer_keywords: ms.assetid: 96fcd78d-1c77-4206-8928-3a0579476ef4 --- # Walkthrough: Hosting a Windows Forms Composite Control in WPF + [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] provides a rich environment for creating applications. However, when you have a substantial investment in Windows Forms code, it can be more effective to reuse at least some of that code in your [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] application rather than to rewrite it from scratch. The most common scenario is when you have existing Windows Forms controls. In some cases, you might not even have access to the source code for these controls. [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] provides a straightforward procedure for hosting such controls in a [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] application. For example, you can use [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] for most of your programming while hosting your specialized controls. This walkthrough steps you through an application that hosts a Windows Forms composite control to perform data entry in a [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] application. The composite control is packaged in a DLL. This general procedure can be extended to more complex applications and controls. This walkthrough is designed to be nearly identical in appearance and functionality to [Walkthrough: Hosting a WPF Composite Control in Windows Forms](walkthrough-hosting-a-wpf-composite-control-in-windows-forms.md). The primary difference is that the hosting scenario is reversed. @@ -23,13 +24,14 @@ ms.assetid: 96fcd78d-1c77-4206-8928-3a0579476ef4 - Implementing the WPF host application. - For a complete code listing of the tasks illustrated in this walkthrough, see [Hosting a Windows Forms Composite Control in WPF Sample](https://go.microsoft.com/fwlink/?LinkID=159999). + For a complete code listing of the tasks illustrated in this walkthrough, see [Hosting a Windows Forms Composite Control in WPF Sample](https://github.com/microsoft/WPF-Samples/tree/master/Migration%20and%20Interoperability/HostingWfInWPF). ## Prerequisites You need Visual Studio to complete this walkthrough. ## Implementing the Windows Forms Composite Control + The Windows Forms composite control used in this example is a simple data-entry form. This form takes the user's name and address and then uses a custom event to return that information to the host. The following illustration shows the rendered control. The following image shows a Windows Forms composite control: @@ -37,6 +39,7 @@ You need Visual Studio to complete this walkthrough. ![Screenshot that shows a simple Windows Forms control.](./media/walkthrough-hosting-a-windows-forms-composite-control-in-wpf/windows-forms-control.gif) ### Creating the Project + To start the project: 1. Launch Visual Studio, and open the **New Project** dialog box. @@ -64,6 +67,7 @@ You need Visual Studio to complete this walkthrough. - System.Xml ### Adding Controls to the Form + To add controls to the form: - Open `MyControl1` in the designer. @@ -83,6 +87,7 @@ You need Visual Studio to complete this walkthrough. Add two controls labeled **OK** and **Cancel**. In the example, the button names are `btnOK` and `btnCancel`, respectively. ### Implementing the Supporting Code + Open the form in code view. The control returns the collected data to its host by raising the custom `OnButtonClick` event. The data is contained in the event argument object. The following code shows the event and delegate declaration. Add the following code to the `MyControl1` class. @@ -105,6 +110,7 @@ You need Visual Studio to complete this walkthrough. [!code-vb[WpfHostingWindowsFormsControl#4](~/samples/snippets/visualbasic/VS_Snippets_Wpf/WpfHostingWindowsFormsControl/VisualBasic/MyControls/MyControl1.vb#4)] ### Giving the Assembly a Strong Name and Building the Assembly + For this assembly to be referenced by a [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] application, it must have a strong name. To create a strong name, create a key file with Sn.exe and add it to your project. 1. Open a Visual Studio command prompt. To do so, click the **Start** menu, and then select **All Programs/Microsoft Visual Studio 2010/Visual Studio Tools/Visual Studio Command Prompt**. This launches a console window with customized environment variables. @@ -122,6 +128,7 @@ You need Visual Studio to complete this walkthrough. 5. Build the solution. The build will produce a DLL named MyControls.dll. ## Implementing the WPF Host Application + The [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] host application uses the control to host `MyControl1`. The application handles the `OnButtonClick` event to receive the data from the control. It also has a collection of option buttons that enable you to change some of the control's properties from the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] application. The following illustration shows the finished application. The following image shows the complete application, including the control embedded in the WPF application: @@ -129,6 +136,7 @@ The following image shows the complete application, including the control embedd ![Screenshot that shows a control embedded in a WPF page.](./media/walkthrough-hosting-a-windows-forms-composite-control-in-wpf/windows-presentation-foundation-page-control.gif) ### Creating the Project + To start the project: 1. Open Visual Studio, and select **New Project**. @@ -152,6 +160,7 @@ The following image shows the complete application, including the control embedd 4. Add a reference to the WindowsFormsIntegration assembly, which is named WindowsFormsIntegration.dll. ### Implementing the Basic Layout + The [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)] of the host application is implemented in MainWindow.xaml. This file contains [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] markup that defines the layout, and hosts the Windows Forms control. The application is divided into three regions: - The **Control Properties** panel, which contains a collection of option buttons that you can use to modify various properties of the hosted control. @@ -169,6 +178,7 @@ The following image shows the complete application, including the control embedd The first element contains several sets of controls that enable you to modify various default properties of the hosted control. That is followed by a element, which hosts `MyControl1`. The final element contains several elements that display the data that is returned by the hosted control. The ordering of the elements and the and attribute settings embed the hosted control into the window with no gaps or distortion. #### Hosting the Control + The following edited version of the previous XAML focuses on the elements that are needed to host `MyControl1`. [!code-xaml[WpfHostingWindowsFormsControl#101](~/samples/snippets/csharp/VS_Snippets_Wpf/WpfHostingWindowsFormsControl/CSharp/WpfHost/Page1.xaml#101)] @@ -183,6 +193,7 @@ The following image shows the complete application, including the control embedd - `mcl:MyControl1`, which represents `MyControl1`, is added to the element's child collection. As a result, this Windows Forms control is rendered as part of the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] window, and you can communicate with the control from the application. ### Implementing the Code-Behind File + The code-behind file, MainWindow.xaml.vb or MainWindow.xaml.cs, contains the procedural code that implements the functionality of the [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] discussed in the preceding section. The primary tasks are: - Attaching an event handler to `MyControl1`'s `OnButtonClick` event. @@ -192,6 +203,7 @@ The following image shows the complete application, including the control embedd - Displaying the data collected by the control. #### Initializing the Application + The initialization code is contained in an event handler for the window's event and attaches an event handler to the control's `OnButtonClick` event. In MainWindow.xaml.vb or MainWindow.xaml.cs, add the following code to the `MainWindow` class. @@ -214,6 +226,7 @@ using MyControls; ``` #### Handling the OnButtonClick Event + `MyControl1` raises the `OnButtonClick` event when the user clicks either of the control's buttons. Add the following code to the `MainWindow` class. @@ -224,6 +237,7 @@ using MyControls; The data in the text boxes is packed into the `MyControlEventArgs` object. If the user clicks the **OK** button, the event handler extracts the data and displays it in the panel below `MyControl1`. #### Modifying the Control’s Properties + The element exposes several of the hosted control's default properties. As a result, you can change the appearance of the control to match the style of your application more closely. The sets of option buttons in the left panel enable the user to modify several color and font properties. Each set of buttons has a handler for the event, which detects the user's option button selections and changes the corresponding property on the control. Add the following code to the `MainWindow` class. diff --git a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-localizing-a-hybrid-application.md b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-localizing-a-hybrid-application.md index bf2a6006fa..3d9f210ae6 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-localizing-a-hybrid-application.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-localizing-a-hybrid-application.md @@ -22,7 +22,7 @@ Tasks illustrated in this walkthrough include: - Using the LocBaml tool to produce a satellite assembly. -For a complete code listing of the tasks illustrated in this walkthrough, see [Localizing a Hybrid Application Sample](https://go.microsoft.com/fwlink/?LinkID=160015). +For a complete code listing of the tasks illustrated in this walkthrough, see [Localizing a Hybrid Application Sample](https://github.com/microsoft/WPF-Samples/tree/master/Migration%20and%20Interoperability/LocalizingWpfInWf). When you are finished, you will have a localized hybrid application. @@ -171,5 +171,5 @@ Your localized content is stored in a resource-only *satellite assembly*. Use th - - - [Localize an Application](how-to-localize-an-application.md) -- [Walkthrough: Localizing Windows Forms](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/y99d1cd3(v=vs.100)) +- [Walkthrough: Localizing Windows Forms](/previous-versions/visualstudio/visual-studio-2010/y99d1cd3(v=vs.100)) - [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-mapping-properties-using-the-elementhost-control.md b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-mapping-properties-using-the-elementhost-control.md index d5d9afbf31..c38a67cad2 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-mapping-properties-using-the-elementhost-control.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-mapping-properties-using-the-elementhost-control.md @@ -23,8 +23,6 @@ Tasks illustrated in this walkthrough include: - Extending a default property mapping. -For a complete code listing of the tasks illustrated in this walkthrough, see [Mapping Properties Using the ElementHost Control Sample](https://go.microsoft.com/fwlink/?LinkID=160018). - When you are finished, you will be able to map Windows Forms properties to corresponding [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] properties on a hosted element. ## Prerequisites @@ -56,7 +54,7 @@ You need the following components to complete this walkthrough: 4. Open `Form1` in the Windows Forms Designer. Double-click the form to add an event handler for the event. -5. Return to the Windows Forms Designer and add an event handler for the form's event. For more information, see [How to: Create Event Handlers Using the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/zwwsdtbk(v=vs.100)). +5. Return to the Windows Forms Designer and add an event handler for the form's event. For more information, see [How to: Create Event Handlers Using the Designer](/previous-versions/visualstudio/visual-studio-2010/zwwsdtbk(v=vs.100)). 6. Declare an field in the `Form1` class. diff --git a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-mapping-properties-using-the-windowsformshost-element.md b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-mapping-properties-using-the-windowsformshost-element.md index 1a58fac67f..b7561213b7 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-mapping-properties-using-the-windowsformshost-element.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-mapping-properties-using-the-windowsformshost-element.md @@ -27,8 +27,6 @@ Tasks illustrated in this walkthrough include: - Extending a default property mapping. -For a complete code listing of the tasks illustrated in this walkthrough, see [Mapping Properties Using the WindowsFormsHost Element Sample](https://go.microsoft.com/fwlink/?LinkID=160019). - When you are finished, you will be able to map [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] properties to corresponding properties on a hosted Windows Forms control. ## Prerequisites diff --git a/dotnet-desktop-guide/framework/wpf/advanced/windows-forms-controls-and-equivalent-wpf-controls.md b/dotnet-desktop-guide/framework/wpf/advanced/windows-forms-controls-and-equivalent-wpf-controls.md index 8625731337..502678cbc3 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/windows-forms-controls-and-equivalent-wpf-controls.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/windows-forms-controls-and-equivalent-wpf-controls.md @@ -9,6 +9,7 @@ helpviewer_keywords: ms.assetid: 8a157e6b-8054-46db-a5cf-a78966acc7a1 --- # Windows Forms Controls and Equivalent WPF Controls + Many Windows Forms controls have equivalent [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] controls, but some Windows Forms controls have no equivalents in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]. This topic compares control types provided by the two technologies. You can always use interoperation to host Windows Forms controls that do not have equivalents in your [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]-based applications. @@ -83,7 +84,7 @@ Many Windows Forms controls have equivalent [!INCLUDE[TLA2#tla_winclient](../../ - - -- [WPF Designer for Windows Forms Developers](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/cc165605(v=vs.100)) +- [WPF Designer for Windows Forms Developers](/previous-versions/visualstudio/visual-studio-2010/cc165605(v=vs.100)) - [Walkthrough: Hosting a Windows Forms Control in WPF](walkthrough-hosting-a-windows-forms-control-in-wpf.md) - [Walkthrough: Hosting a WPF Composite Control in Windows Forms](walkthrough-hosting-a-wpf-composite-control-in-windows-forms.md) - [Migration and Interoperability](migration-and-interoperability.md) diff --git a/dotnet-desktop-guide/framework/wpf/advanced/xaml-namespaces-and-namespace-mapping-for-wpf-xaml.md b/dotnet-desktop-guide/framework/wpf/advanced/xaml-namespaces-and-namespace-mapping-for-wpf-xaml.md index cf357a2f8d..2213f0e8ac 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/xaml-namespaces-and-namespace-mapping-for-wpf-xaml.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/xaml-namespaces-and-namespace-mapping-for-wpf-xaml.md @@ -17,13 +17,17 @@ helpviewer_keywords: ms.assetid: 5c0854e3-7470-435d-9fe2-93eec9d3634e --- # XAML Namespaces and Namespace Mapping for WPF XAML + This topic further explains the presence and purpose of the two XAML namespace mappings as often found in the root tag of a WPF XAML file. It also describes how to produce similar mappings for using elements that are defined in your own code, and/or within separate assemblies. -## What is a XAML Namespace? +## What is a XAML Namespace + A XAML namespace is really an extension of the concept of an XML namespace. The techniques of specifying a XAML namespace rely on the XML namespace syntax, the convention of using URIs as namespace identifiers, using prefixes to provide a means to reference multiple namespaces from the same markup source, and so on. The primary concept that is added to the XAML definition of the XML namespace is that a XAML namespace implies both a scope of uniqueness for the markup usages, and also influences how markup entities are potentially backed by specific CLR namespaces and referenced assemblies. This latter consideration is also influenced by the concept of a XAML schema context. But for purposes of how WPF works with XAML namespaces, you can generally think of XAML namespaces in terms of a default XAML namespace, the XAML language namespace, and any further XAML namespaces as mapped by your XAML markup directly to specific backing CLR namespaces and referenced assemblies. + ## The WPF and XAML Namespace Declarations + Within the namespace declarations in the root tag of many XAML files, you will see that there are typically two XML namespace declarations. The first declaration maps the overall WPF client / framework XAML namespace as the default: `xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"` @@ -37,7 +41,9 @@ This topic further explains the presence and purpose of the two XAML namespace m The `x:` prefix convention for mapping the XAML language intrinsics support is followed by project templates, sample code, and the documentation of language features within this SDK. The XAML namespace defines many commonly-used features that are necessary even for basic WPF applications. For instance, in order to join any code-behind to a XAML file through a partial class, you must name that class as the `x:Class` attribute in the root element of the relevant XAML file. Or, any element as defined in a XAML page that you wish to access as a keyed resource should have the `x:Key` attribute set on the element in question. For more information on these and other aspects of XAML see [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml) or [XAML Syntax In Detail](xaml-syntax-in-detail.md). + ## Mapping to Custom Classes and Assemblies + You can map XML namespaces to assemblies using a series of tokens within an `xmlns` prefix declaration, similar to how the standard WPF and XAML-intrinsics XAML namespaces are mapped to prefixes. The syntax takes the following possible named tokens and following values: @@ -49,6 +55,7 @@ This topic further explains the presence and purpose of the two XAML namespace m Note that the character separating the `clr-namespace` token from its value is a colon (:) whereas the character separating the `assembly` token from its value is an equals sign (=). The character to use between these two tokens is a semicolon. Also, do not include any white space anywhere in the declaration. ### A Basic Custom Mapping Example + The following code defines an example custom class: ```csharp @@ -94,17 +101,21 @@ End Namespace ``` ### Mapping to Current Assemblies + `assembly` can be omitted if the `clr-namespace` referenced is being defined within the same assembly as the application code that is referencing the custom classes. Or, an equivalent syntax for this case is to specify `assembly=`, with no string token following the equals sign. Custom classes cannot be used as the root element of a page if defined in the same assembly. Partial classes do not need to be mapped; only classes that are not the partial class of a page in your application need to be mapped if you intend to reference them as elements in XAML. + ## Mapping CLR Namespaces to XML Namespaces in an Assembly + WPF defines a CLR attribute that is consumed by XAML processors in order to map multiple CLR namespaces to a single XAML namespace. This attribute, , is placed at the assembly level in the source code that produces the assembly. The WPF assembly source code uses this attribute to map the various common namespaces, such as and , to the `http://schemas.microsoft.com/winfx/2006/xaml/presentation` namespace. The takes two parameters: the XML/XAML namespace name, and the CLR namespace name. More than one can exist to map multiple CLR namespaces to the same XML namespace. Once mapped, members of those namespaces can also be referenced without full qualification if desired by providing the appropriate `using` statement in the partial-class code-behind page. For more details, see . ## Designer Namespaces and Other Prefixes From XAML Templates + If you are working with development environments and/or design tools for WPF XAML, you may notice that there are other defined XAML namespaces / prefixes within the XAML markup. WPF Designer for Visual Studio uses a designer namespace that is typically mapped to the prefix `d:`. More recent project templates for WPF might pre-map this XAML namespace to support interchange of the XAML between WPF Designer for Visual Studio and other design environments. This design XAML namespace is used to perpetuate design state while roundtripping XAML-based UI in the designer. It is also used for features such as `d:IsDataSource`, which enable runtime data sources in a designer. @@ -112,6 +123,7 @@ End Namespace Another prefix you might see mapped is `mc:`. `mc:` is for markup compatibility, and is leveraging a markup compatibility pattern that is not necessarily XAML-specific. To some extent, the markup compatibility features can be used to exchange XAML between frameworks or across other boundaries of backing implementation, work between XAML schema contexts, provide compatibility for limited modes in designers, and so on. For more information on markup compatibility concepts and how they relate to WPF, see [Markup Compatibility (mc:) Language Features](markup-compatibility-mc-language-features.md). ## WPF and Assembly Loading + The XAML schema context for WPF integrates with the WPF application model, which in turn uses the CLR-defined concept of . The following sequence describes how XAML schema context interprets how to either load assemblies or find types at run time or design time, based on the WPF use of and other factors. 1. Iterate through the , looking for an already-loaded assembly that matches all aspects of the name, starting from the most recently loaded assembly. @@ -132,5 +144,5 @@ End Namespace ## See also -- [Understanding XML Namespaces](https://docs.microsoft.com/previous-versions/aa468565(v=msdn.10)) +- [Understanding XML Namespaces](/previous-versions/aa468565(v=msdn.10)) - [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/application-management-overview.md b/dotnet-desktop-guide/framework/wpf/app-development/application-management-overview.md index 19f9621ecd..2d535aa50c 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/application-management-overview.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/application-management-overview.md @@ -109,7 +109,7 @@ The resulting code augments your application definition with additional infrastr ## Getting the Current Application -Because the functionality of the class are shared across an application, there can be only one instance of the class per . To enforce this, the class is implemented as a singleton class (see [Implementing Singleton in C#](https://docs.microsoft.com/previous-versions/msp-n-p/ff650316(v=pandp.10))), which creates a single instance of itself and provides shared access to it with the `static` property. +Because the functionality of the class are shared across an application, there can be only one instance of the class per . To enforce this, the class is implemented as a singleton class (see [Implementing Singleton in C#](/previous-versions/msp-n-p/ff650316(v=pandp.10))), which creates a single instance of itself and provides shared access to it with the `static` property. The following code shows how to acquire a reference to the object for the current . @@ -387,5 +387,5 @@ Likewise, the following figure illustrates the key events in the lifetime of an - [Navigation Overview](navigation-overview.md) - [WPF Application Resource, Content, and Data Files](wpf-application-resource-content-and-data-files.md) - [Pack URIs in WPF](pack-uris-in-wpf.md) -- [Application Model: How-to Topics](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms749013(v=vs.100)) +- [Application Model: How-to Topics](/previous-versions/dotnet/netframework-4.0/ms749013(v=vs.100)) - [Application Development](index.md) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/build-and-deploy-how-to-topics.md b/dotnet-desktop-guide/framework/wpf/app-development/build-and-deploy-how-to-topics.md index 8f7c4f64f6..3e0fb334f2 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/build-and-deploy-how-to-topics.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/build-and-deploy-how-to-topics.md @@ -25,5 +25,5 @@ The following topics show how to create project files for the various [!INCLUDE[ - [Building a WPF Application](building-a-wpf-application-wpf.md) - [Deploying a WPF Application](deploying-a-wpf-application-wpf.md) - [Walkthrough: My first WPF desktop application](../getting-started/walkthrough-my-first-wpf-desktop-application.md) -- [How to: Create a New WPF Browser Application Project](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/bb628663(v=vs.100)) -- [Determine the Installed Version of WPF (.NET Framework 3.5)](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/aa349641(v=vs.90)) +- [How to: Create a New WPF Browser Application Project](/previous-versions/visualstudio/visual-studio-2010/bb628663(v=vs.100)) +- [Determine the Installed Version of WPF (.NET Framework 3.5)](/previous-versions/dotnet/netframework-3.5/aa349641(v=vs.90)) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/deploying-a-wpf-application-wpf.md b/dotnet-desktop-guide/framework/wpf/app-development/deploying-a-wpf-application-wpf.md index 7d5ca30755..30ef54c3a1 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/deploying-a-wpf-application-wpf.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/deploying-a-wpf-application-wpf.md @@ -12,7 +12,9 @@ ms.assetid: 12cadca0-b32c-4064-9a56-e6a306dcc76d After Windows Presentation Foundation (WPF) applications are built, they need to be deployed. Windows and the .NET Framework include several deployment technologies. The deployment technology that is used to deploy a WPF application depends on the application type. This topic provides a brief overview of each deployment technology, and how they are used in conjunction with the deployment requirements of each WPF application type. + ## Deployment Technologies + Windows and the .NET Framework include several deployment technologies, including: - XCopy deployment. @@ -22,7 +24,9 @@ After Windows Presentation Foundation (WPF) applications are built, they need to - ClickOnce deployment. + ### XCopy Deployment + XCopy deployment refers to the use of the XCopy command-line program to copy files from one location to another. XCopy deployment is suitable under the following circumstances: - The application is self-contained. It does not need to update the client to run. @@ -34,7 +38,9 @@ After Windows Presentation Foundation (WPF) applications are built, they need to Although XCopy is suitable for simple deployment scenarios, it is limited when more complex deployment capabilities are required. In particular, using XCopy often incurs the overhead for creating, executing, and maintaining scripts for managing deployment in a robust way. Furthermore, XCopy does not support versioning, uninstallation, or rollback. + ### Windows Installer + Windows Installer allows applications to be packaged as self-contained executables that can be easily distributed to clients and run. Furthermore, Windows Installer is installed with Windows and enables integration with the desktop, the Start menu, and the Programs control panel. Windows Installer simplifies the installation and uninstallation of applications, but it does not provide facilities for ensuring that installed applications are kept up-to-date from a versioning standpoint. @@ -42,7 +48,9 @@ After Windows Presentation Foundation (WPF) applications are built, they need to For more information about Windows Installer, see [Windows Installer Deployment](/visualstudio/deployment/deploying-applications-services-and-components#create-an-installer-package-windows-desktop). + ### ClickOnce Deployment + ClickOnce enables Web-style application deployment for non-Web applications. Applications are published to and deployed from Web or file servers. Although ClickOnce does not support the full range of client features that Windows Installer-installed applications do, it does support a subset that includes the following: - Integration with the Start menu and Programs control panel. @@ -58,7 +66,9 @@ After Windows Presentation Foundation (WPF) applications are built, they need to For more information about ClickOnce, see [ClickOnce Security and Deployment](/visualstudio/deployment/clickonce-security-and-deployment). + ## Deploying WPF Applications + The deployment options for a WPF application depend on the type of application. From a deployment perspective, WPF has three significant application types: - Standalone applications. @@ -68,11 +78,15 @@ After Windows Presentation Foundation (WPF) applications are built, they need to - XAML browser applications (XBAPs). + ### Deploying Standalone Applications + Standalone applications are deployed using either ClickOnce or Windows Installer. Either way, standalone applications require full trust to run. Full trust is automatically granted to standalone applications that are deployed using Windows Installer. Standalone applications that are deployed using ClickOnce are not automatically granted full trust. Instead, ClickOnce displays a security warning dialog that users must accept before a standalone application is installed. If accepted, the standalone application is installed and granted full trust. If not, the standalone application is not installed. + ### Deploying Markup-Only XAML Applications + Markup-only [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] pages are usually published to Web servers, like HTML pages, and can be viewed using Internet Explorer. Markup-only [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] pages run within a partial-trust security sandbox with restrictions that are defined by the Internet zone permission set. This provides an equivalent security sandbox to HTML-based Web applications. For more information about security for WPF applications, see [Security](../security-wpf.md). @@ -82,7 +96,9 @@ After Windows Presentation Foundation (WPF) applications are built, they need to For more information about XAML, see [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml). + ### Deploying XAML Browser Applications + XBAPs are compiled applications that require the following three files to be deployed: - *ApplicationName*.exe: The executable assembly application file. @@ -94,7 +110,7 @@ After Windows Presentation Foundation (WPF) applications are built, they need to > [!NOTE] > For more information about deployment and application manifests, see [Building a WPF Application](building-a-wpf-application-wpf.md). - These files are produced when an XBAP is built. For more information, see [How to: Create a New WPF Browser Application Project](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/bb628663(v=vs.100)). Like markup-only [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] pages, XBAPs are typically published to a Web server and viewed using Internet Explorer. + These files are produced when an XBAP is built. For more information, see [How to: Create a New WPF Browser Application Project](/previous-versions/visualstudio/visual-studio-2010/bb628663(v=vs.100)). Like markup-only [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] pages, XBAPs are typically published to a Web server and viewed using Internet Explorer. XBAPs can be deployed to clients using any of the deployment techniques. However, ClickOnce is recommended since it provides the following capabilities: @@ -107,7 +123,9 @@ After Windows Presentation Foundation (WPF) applications are built, they need to For more information about deploying XAML browser applications (XBAPs), see [WPF XAML Browser Applications Overview](wpf-xaml-browser-applications-overview.md). + ## Installing the .NET Framework + To run a WPF application, the Microsoft .NET Framework must be installed on the client. Internet Explorer automatically detects whether clients are installed with .NET Framework when WPF browser-hosted applications are viewed. If the .NET Framework is not installed, Internet Explorer prompts users to install it. To detect whether the .NET Framework is installed, Internet Explorer includes a bootstrapper application that is registered as the fallback Multipurpose Internet Mail Extensions (MIME) handler for content files with the following extensions: .xaml, .xps, .xbap, and .application. If you navigate to these file types and the .NET Framework is not installed on the client, the bootstrapper application requests permission to install it. If permission is not provided, neither the .NET Framework nor the application is installed. diff --git a/dotnet-desktop-guide/framework/wpf/app-development/how-to-add-a-splash-screen-to-a-wpf-application.md b/dotnet-desktop-guide/framework/wpf/app-development/how-to-add-a-splash-screen-to-a-wpf-application.md index 5199df6dca..8039666bec 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/how-to-add-a-splash-screen-to-a-wpf-application.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/how-to-add-a-splash-screen-to-a-wpf-application.md @@ -42,4 +42,4 @@ In **Solution Explorer**, delete the splash screen image. ## See also - -- [How to: Add Existing Items to a Project](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/9f4t9t92(v=vs.100)) +- [How to: Add Existing Items to a Project](/previous-versions/visualstudio/visual-studio-2010/9f4t9t92(v=vs.100)) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/how-to-create-an-add-in-that-is-a-ui.md b/dotnet-desktop-guide/framework/wpf/app-development/how-to-create-an-add-in-that-is-a-ui.md index 2dc0613582..24b68787db 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/how-to-create-an-add-in-that-is-a-ui.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/how-to-create-an-add-in-that-is-a-ui.md @@ -14,6 +14,7 @@ helpviewer_keywords: ms.assetid: 86375525-282b-4039-8352-8680051a10ea --- # How to: Create an Add-In That Is a UI + This example shows how to create an add-in that is a Windows Presentation Foundation (WPF) which is hosted by a WPF standalone application. The add-in is a UI that is a WPF user control. The content of the user control is a single button that, when clicked, displays a message box. The WPF standalone application hosts the add-in UI as the content of the main application window. @@ -22,14 +23,16 @@ This example shows how to create an add-in that is a Windows Presentation Founda This example highlights the WPF extensions to the .NET Framework add-in model that enable this scenario, and assumes the following: -- Knowledge of the .NET Framework add-in model, including pipeline, add-in, and host development. If you are unfamiliar with these concepts, see [Add-ins and Extensibility](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)). For a tutorial that demonstrates the implementation of a pipeline, an add-in, and a host application, see [Walkthrough: Creating an Extensible Application](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb788290(v%3dvs.100)). +- Knowledge of the .NET Framework add-in model, including pipeline, add-in, and host development. If you are unfamiliar with these concepts, see [Add-ins and Extensibility](/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)). For a tutorial that demonstrates the implementation of a pipeline, an add-in, and a host application, see [Walkthrough: Creating an Extensible Application](/previous-versions/dotnet/netframework-4.0/bb788290(v%3dvs.100)). - Knowledge of the WPF extensions to the .NET Framework add-in model. See [WPF Add-Ins Overview](wpf-add-ins-overview.md). ## Example + To create an add-in that is a WPF UI requires specific code for each pipeline segment, the add-in, and the host application. + ## Implementing the Contract Pipeline Segment When an add-in is a UI, the contract for the add-in must implement . In the example, `IWPFAddInContract` implements , as shown in the following code. @@ -38,6 +41,7 @@ When an add-in is a UI, the contract for the add-in must implement + ## Implementing the Add-In View Pipeline Segment Because the add-in is implemented as a subclass of the type, the add-in view must also subclass . The following code shows the add-in view of the contract, implemented as the `WPFAddInView` class. @@ -48,6 +52,7 @@ Because the add-in is implemented as a subclass of the . Consequently, the add-in UI should also derive from . + ## Implementing the Add-In-Side Adapter Pipeline Segment While the contract is an , the add-in is a (as specified by the add-in view pipeline segment). Therefore, the must be converted to an before crossing the isolation boundary. This work is performed by the add-in-side adapter by calling , as shown in the following code. @@ -63,6 +68,7 @@ In the add-in model where an add-in returns a UI (see [Create an Add-In That Ret Because the add-in-side adapter implements an interface that derives from , you also need to implement , although this is ignored when is overridden. + ## Implementing the Host View Pipeline Segment In this model, the host application typically expects the host view to be a subclass. The host-side adapter must convert the to a after the crosses the isolation boundary. Because a method isn't being called by the host application to get the , the host view must "return" the by containing it. Consequently, the host view must derive from a subclass of that can contain other UIs, such as . The following code shows the host view of the contract, implemented as the `WPFAddInHostView` class. @@ -71,6 +77,7 @@ In this model, the host application typically expects the host view to be a + ## Implementing the Host-Side Adapter Pipeline Segment While the contract is an , the host application expects a (as specified by the host view). Consequently, the must be converted to a after crossing the isolation boundary, before being set as content of the host view (which derives from ). @@ -85,6 +92,7 @@ As you can see, the host-side adapter acquires the to a by calling . Finally, the is set as the content of the host view. + ## Implementing the Add-In With the add-in-side adapter and add-in view in place, the add-in can be implemented by deriving from the add-in view, as shown in the following code. @@ -95,6 +103,7 @@ With the add-in-side adapter and add-in view in place, the add-in can be impleme From this example, you can see one interesting benefit of this model: add-in developers only need to implement the add-in (since it is the UI as well), rather than both an add-in class and an add-in UI. + ## Implementing the Host Application With the host-side adapter and host view created, the host application can use the .NET Framework add-in model to open the pipeline and acquire a host view of the add-in. These steps are shown in the following code. @@ -114,5 +123,5 @@ The host application uses typical .NET Framework add-in model code to activate t ## See also -- [Add-ins and Extensibility](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)) +- [Add-ins and Extensibility](/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)) - [WPF Add-Ins Overview](wpf-add-ins-overview.md) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/how-to-create-an-add-in-that-returns-a-ui.md b/dotnet-desktop-guide/framework/wpf/app-development/how-to-create-an-add-in-that-returns-a-ui.md index 9c67ed57fe..7b87d3bd23 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/how-to-create-an-add-in-that-returns-a-ui.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/how-to-create-an-add-in-that-returns-a-ui.md @@ -11,6 +11,7 @@ helpviewer_keywords: ms.assetid: 57f274b7-4c66-4b72-92eb-81939a393776 --- # How to: Create an Add-In That Returns a UI + This example shows how to create an add-in that returns a Windows Presentation Foundation (WPF) to a host WPF standalone application. The add-in returns a UI that is a WPF user control. The content of the user control is a single button that, when clicked, displays a message box. The WPF standalone application hosts the add-in and displays the user control (returned by the add-in) as the content of the main application window. @@ -19,50 +20,63 @@ This example shows how to create an add-in that returns a Windows Presentation F This example highlights the WPF extensions to the .NET Framework add-in model that enable this scenario, and assumes the following: -- Knowledge of the .NET Framework add-in model, including pipeline, add-in, and host development. If you are unfamiliar with these concepts, see [Add-ins and Extensibility](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)). For a tutorial that demonstrates the implementation of a pipeline, an add-in, and a host application, see [Walkthrough: Creating an Extensible Application](/previous-versions/dotnet/netframework-4.0/bb788290(v%3dvs.100)). +- Knowledge of the .NET Framework add-in model, including pipeline, add-in, and host development. If you are unfamiliar with these concepts, see [Add-ins and Extensibility](/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)). For a tutorial that demonstrates the implementation of a pipeline, an add-in, and a host application, see [Walkthrough: Creating an Extensible Application](/previous-versions/dotnet/netframework-4.0/bb788290(v%3dvs.100)). - Knowledge of the WPF extensions to the .NET Framework add-in model, which can be found here: [WPF Add-Ins Overview](wpf-add-ins-overview.md). ## Example + To create an add-in that returns a WPF UI requires specific code for each pipeline segment, the add-in, and the host application. + ## Implementing the Contract Pipeline Segment + A method must be defined by the contract for returning a UI, and its return value must be of type . This is demonstrated by the `GetAddInUI` method of the `IWPFAddInContract` contract in the following code. [!code-csharp[SimpleAddInReturnsAUISample#ContractCode](~/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/CSharp/Contracts/IWPFAddInContract.cs#contractcode)] [!code-vb[SimpleAddInReturnsAUISample#ContractCode](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/VisualBasic/Contracts/IWPFAddInContract.vb#contractcode)] + ## Implementing the Add-In View Pipeline Segment + Because the add-in implements the UIs it provides as subclasses of , the method on the add-in view that correlates to `IWPFAddInView.GetAddInUI` must return a value of type . The following code shows the add-in view of the contract, implemented as an interface. [!code-csharp[SimpleAddInReturnsAUISample#AddInViewCode](~/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/CSharp/AddInViews/IWPFAddInView.cs#addinviewcode)] [!code-vb[SimpleAddInReturnsAUISample#AddInViewCode](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/VisualBasic/AddInViews/IWPFAddInView.vb#addinviewcode)] + ## Implementing the Add-In-Side Adapter Pipeline Segment + The contract method returns an , but the add-in returns a (as specified by the add-in view). Consequently, the must be converted to an before crossing the isolation boundary. This work is performed by the add-in-side adapter by calling , as shown in the following code. [!code-csharp[SimpleAddInReturnsAUISample#AddInSideAdapterCode](~/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/CSharp/AddInSideAdapters/WPFAddIn_ViewToContractAddInSideAdapter.cs#addinsideadaptercode)] [!code-vb[SimpleAddInReturnsAUISample#AddInSideAdapterCode](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/VisualBasic/AddInSideAdapters/WPFAddIn_ViewToContractAddInSideAdapter.vb#addinsideadaptercode)] + ## Implementing the Host View Pipeline Segment + Because the host application will display a , the method on the host view that correlates to `IWPFAddInHostView.GetAddInUI` must return a value of type . The following code shows the host view of the contract, implemented as an interface. [!code-csharp[SimpleAddInReturnsAUISample#HostViewCode](~/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/CSharp/HostViews/IWPFAddInHostView.cs#hostviewcode)] [!code-vb[SimpleAddInReturnsAUISample#HostViewCode](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/VisualBasic/HostViews/IWPFAddInHostView.vb#hostviewcode)] + ## Implementing the Host-Side Adapter Pipeline Segment + The contract method returns an , but the host application expects a (as specified by the host view). Consequently, the must be converted to a after crossing the isolation boundary. This work is performed by the host-side adapter by calling , as shown in the following code. [!code-csharp[SimpleAddInReturnsAUISample#HostSideAdapterCode](~/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/CSharp/HostSideAdapters/WPFAddIn_ContractToViewHostSideAdapter.cs#hostsideadaptercode)] [!code-vb[SimpleAddInReturnsAUISample#HostSideAdapterCode](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/VisualBasic/HostSideAdapters/WPFAddIn_ContractToViewHostSideAdapter.vb#hostsideadaptercode)] + ## Implementing the Add-In + With the add-in-side adapter and add-in view created, the add-in (`WPFAddIn1.AddIn`) must implement the `IWPFAddInView.GetAddInUI` method to return a object (a in this example). The implementation of the , `AddInUI`, is shown by the following code. [!code-xaml[SimpleAddInReturnsAUISample#AddInUIMarkup](~/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/CSharp/WPFAddIn1/AddInUI.xaml#addinuimarkup)] @@ -76,7 +90,9 @@ This example shows how to create an add-in that returns a Windows Presentation F [!code-vb[SimpleAddInReturnsAUISample#AddInCode](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/VisualBasic/WPFAddIn1/AddIn.vb#addincode)] + ## Implementing the Host Application + With the host-side adapter and host view created, the host application can use the .NET Framework add-in model to open the pipeline, acquire a host view of the add-in, and call the `IWPFAddInHostView.GetAddInUI` method. These steps are shown in the following code. [!code-csharp[SimpleAddInReturnsAUISample#GetUICode](~/samples/snippets/csharp/VS_Snippets_Wpf/SimpleAddInReturnsAUISample/CSharp/Host/MainWindow.xaml.cs#getuicode)] @@ -84,5 +100,5 @@ This example shows how to create an add-in that returns a Windows Presentation F ## See also -- [Add-ins and Extensibility](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)) +- [Add-ins and Extensibility](/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)) - [WPF Add-Ins Overview](wpf-add-ins-overview.md) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/how-to-detect-whether-the-net-framework-3-0-is-installed.md b/dotnet-desktop-guide/framework/wpf/app-development/how-to-detect-whether-the-net-framework-3-0-is-installed.md index 87439dcd12..ee82d0a0a1 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/how-to-detect-whether-the-net-framework-3-0-is-installed.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/how-to-detect-whether-the-net-framework-3-0-is-installed.md @@ -8,13 +8,16 @@ helpviewer_keywords: ms.assetid: 7f71d652-1749-4379-945a-aa2e3994cb43 --- # How to: Detect Whether the .NET Framework 3.0 Is Installed + Before administrators can deploy Microsoft .NET Framework applications on a system, they must first confirm that the .NET Framework runtime is present. This topic provides a script written in HTML/JavaScript that administrators can use to determine whether the .NET Framework is present on a system. > [!NOTE] -> For more detailed information on installing, deploying, and detecting the Microsoft .NET Framework, see the discussion in [Deploying Microsoft .NET Framework Version 3.0](https://docs.microsoft.com/previous-versions/dotnet/articles/aa480198(v=msdn.10)). +> For more detailed information on installing, deploying, and detecting the Microsoft .NET Framework, see the discussion in [Deploying Microsoft .NET Framework Version 3.0](/previous-versions/dotnet/articles/aa480198(v=msdn.10)). + ## Detect the ".NET CLR" User-Agent String + When .NET Framework is installed, the MSI adds ".NET CLR" and the version number to the UserAgent string. The following example shows a script embedded in a simple HTML page. The script searches the UserAgent string to determine whether .NET Framework is installed, and displays a status message on the results of the search. ```html diff --git a/dotnet-desktop-guide/framework/wpf/app-development/how-to-use-an-application-scope-resource-dictionary.md b/dotnet-desktop-guide/framework/wpf/app-development/how-to-use-an-application-scope-resource-dictionary.md index 0bfea19b15..15a75614a0 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/how-to-use-an-application-scope-resource-dictionary.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/how-to-use-an-application-scope-resource-dictionary.md @@ -12,10 +12,12 @@ helpviewer_keywords: ms.assetid: 53857682-bd2c-4f2c-8f25-1307d0b451a2 --- # How to: Use an Application-Scope Resource Dictionary + This example shows how to define and use an application-scope custom resource dictionary. ## Example - exposes an application-scope store for shared resources: . By default, the property is initialized with an instance of the type. You use this instance when you get and set application-scope properties using . For more information, see [How to: Get and Set an Application-Scope Resource](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/aa348547(v=vs.100)). + + exposes an application-scope store for shared resources: . By default, the property is initialized with an instance of the type. You use this instance when you get and set application-scope properties using . For more information, see [How to: Get and Set an Application-Scope Resource](/previous-versions/dotnet/netframework-4.0/aa348547(v=vs.100)). If you have multiple resources that you set using , you can instead use a custom resource dictionary to store those resources and set with it instead. The following shows how you declare a custom resource dictionary using XAML. diff --git a/dotnet-desktop-guide/framework/wpf/app-development/iwpfhostsupport.md b/dotnet-desktop-guide/framework/wpf/app-development/iwpfhostsupport.md index 8264be0667..7f55edff98 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/iwpfhostsupport.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/iwpfhostsupport.md @@ -6,10 +6,12 @@ helpviewer_keywords: ms.assetid: cc5a0281-de81-4cc1-87e4-0e46b1a811e9 --- # IWpfHostSupport + Applications that host [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] content via PresentationHost.exe implement this interface to provide a point of integration between the host and PresentationHost.exe. ## Remarks - Win32 applications such as Web browsers can host WPF content, including XAML browser applications (XBAPs) and loose XAML. To host WPF content, Win32 applications create an instance of the [WebBrowser control](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)). To be hosted, WPF creates an instance of PresentationHost.exe, which provides the hosted WPF content to the host for display in the [WebBrowser control](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)). + + Win32 applications such as Web browsers can host WPF content, including XAML browser applications (XBAPs) and loose XAML. To host WPF content, Win32 applications create an instance of the [WebBrowser control](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)). To be hosted, WPF creates an instance of PresentationHost.exe, which provides the hosted WPF content to the host for display in the [WebBrowser control](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)). The integration enabled by `IWpfHostSupport` allows PresentationHost.exe to: diff --git a/dotnet-desktop-guide/framework/wpf/app-development/native-wpf-browser-hosting-support-apis.md b/dotnet-desktop-guide/framework/wpf/app-development/native-wpf-browser-hosting-support-apis.md index 9abecca9bd..d83e43a3ed 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/native-wpf-browser-hosting-support-apis.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/native-wpf-browser-hosting-support-apis.md @@ -9,11 +9,13 @@ helpviewer_keywords: ms.assetid: 82c133a8-d760-45fb-a2b9-3a997537f1d4 --- # Native WPF Browser Hosting Support APIs + Hosting of WPF applications in Web browsers is facilitated by an Active Document server (also known as a DocObject) registered out of the WPF Host. Internet Explorer can directly activate and integrate with an Active Document. For hosting of XBAPs and loose XAML documents in Mozilla browsers, WPF provides an NPAPI plugin, which provides a similar hosting environment to the WPF Active Document server as Internet Explorer does. However, the easiest practical way to host XBAPs and XAML documents in other browsers and standalone applications is via the Internet Explorer Web Browser control. The Web Browser control provides the complex Active Document server hosting environment, yet it enables its own host to customize and extend that environment and communicate directly with the current Active Document object. - The WPF Active Document server implements several common hosting interfaces, including [IOleObject](/windows/win32/api/oleidl/nn-oleidl-ioleobject), [IOleDocument](/windows/win32/api/docobj/nn-docobj-ioledocument), [IOleInPlaceActiveObject](/windows/win32/api/oleidl/nn-oleidl-ioleinplaceactiveobject), [IPersistMoniker](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775042(v=vs.85)), [IOleCommandTarget](/windows/win32/api/docobj/nn-docobj-iolecommandtarget). When hosted in the Web Browser control, these interfaces can be queries from the object returned by the [IWebBrowser2::Document](https://docs.microsoft.com/previous-versions/aa752116(v=vs.85)) property. + The WPF Active Document server implements several common hosting interfaces, including [IOleObject](/windows/win32/api/oleidl/nn-oleidl-ioleobject), [IOleDocument](/windows/win32/api/docobj/nn-docobj-ioledocument), [IOleInPlaceActiveObject](/windows/win32/api/oleidl/nn-oleidl-ioleinplaceactiveobject), [IPersistMoniker](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775042(v=vs.85)), [IOleCommandTarget](/windows/win32/api/docobj/nn-docobj-iolecommandtarget). When hosted in the Web Browser control, these interfaces can be queries from the object returned by the [IWebBrowser2::Document](/previous-versions/aa752116(v=vs.85)) property. ## IOleCommandTarget + WPF Active Document server's implementation of [IOleCommandTarget](/windows/win32/api/docobj/nn-docobj-iolecommandtarget) supports numerous navigation-related and browser-specific commands of the standard OLE command group (with a null command group GUID). In addition, it recognizes a custom command group called CGID_PresentationHost. Currently, there is only one command defined within this group. ```cpp @@ -26,5 +28,6 @@ enum PresentationHostCommands { PHCMDID_TABINTO instructs PresentationHost to switch focus to the first or last focusable element in its content, depending on the state of the Shift key. ## In This Section + [IEnumRAWINPUTDEVICE](ienumrawinputdevice.md) [IWpfHostSupport](iwpfhostsupport.md) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/wpf-add-ins-overview.md b/dotnet-desktop-guide/framework/wpf/app-development/wpf-add-ins-overview.md index b26f32dcf2..aece0b3c1b 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/wpf-add-ins-overview.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/wpf-add-ins-overview.md @@ -21,7 +21,7 @@ ms.assetid: 00b4c776-29a8-4dba-b603-280a0cdc2ade ## Prerequisites -Familiarity with the .NET Framework add-in model is required. For more information, see [Add-ins and Extensibility](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)). +Familiarity with the .NET Framework add-in model is required. For more information, see [Add-ins and Extensibility](/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)). @@ -60,7 +60,7 @@ In order for add-ins to be used, host applications need to find them and load th Ultimately, developing a robust add-in model is a non-trivial undertaking. For this reason, the .NET Framework provides an infrastructure for building add-in models. > [!NOTE] -> For more detailed information on add-ins, see [Add-ins and Extensibility](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)). +> For more detailed information on add-ins, see [Add-ins and Extensibility](/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)). @@ -101,7 +101,7 @@ A remotable object is an instance of a class that does one or more of the follow - Has the attribute applied. > [!NOTE] -> For more information regarding the creation of remotable .NET Framework objects, see [Making Objects Remotable](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/wcf3swha(v=vs.100)). +> For more information regarding the creation of remotable .NET Framework objects, see [Making Objects Remotable](/previous-versions/dotnet/netframework-4.0/wcf3swha(v=vs.100)). The WPF UI types are not remotable. To solve the problem, WPF extends the .NET Framework add-in model to enable WPF UI created by add-ins to be displayed from host applications. This support is provided by WPF by two types: the interface and two static methods implemented by the class: and . At a high level, these types and methods are used in the following manner: @@ -121,7 +121,7 @@ How , and, to return a UI, the contract must declare a method with a return value of type . @@ -141,7 +141,7 @@ For an example that demonstrates how to implement an add-in that returns a UI, s When an add-in is a UI, the following are required: -1. The host application, add-in, and pipeline must be created, as described by the .NET Framework [Add-ins and Extensibility](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)) documentation. +1. The host application, add-in, and pipeline must be created, as described by the .NET Framework [Add-ins and Extensibility](/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)) documentation. 2. The contract interface for the add-in must implement . @@ -305,8 +305,8 @@ By default, when multiple application domains are used, the various .NET Framewo ## See also - -- [Add-ins and Extensibility](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)) +- [Add-ins and Extensibility](/previous-versions/dotnet/netframework-4.0/bb384200(v%3dvs.100)) - [Application Domains](/dotnet/framework/app-domains/application-domains) -- [.NET Framework Remoting Overview](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/kwdt6w2k(v=vs.100)) -- [Making Objects Remotable](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/wcf3swha(v=vs.100)) +- [.NET Framework Remoting Overview](/previous-versions/dotnet/netframework-4.0/kwdt6w2k(v=vs.100)) +- [Making Objects Remotable](/previous-versions/dotnet/netframework-4.0/wcf3swha(v=vs.100)) - [How-to Topics](how-to-topics.md) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/wpf-xaml-browser-applications-overview.md b/dotnet-desktop-guide/framework/wpf/app-development/wpf-xaml-browser-applications-overview.md index ddcd0df8f2..8959ec1fe6 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/wpf-xaml-browser-applications-overview.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/wpf-xaml-browser-applications-overview.md @@ -13,6 +13,7 @@ helpviewer_keywords: ms.assetid: 3a7a86a8-75d5-4898-96b9-73da151e5e16 --- # WPF XAML Browser Applications Overview + XAML browser applications (XBAPs) combines features of both Web applications and rich-client applications. Like Web applications, XBAPs can be deployed to a Web server and started from Internet Explorer or Firefox. Like rich-client applications, XBAPs can take advantage of the capabilities of WPF. Developing XBAPs is also similar to rich-client development. This topic provides a simple, high-level introduction to XBAP development and describes where XBAP development differs from standard rich-client development. @@ -29,8 +30,10 @@ XAML browser applications (XBAPs) combines features of both Web applications and - [XBAP Start Time Performance Considerations](#xbap_start_time_performance_considerations) + ## Creating a New XAML Browser Application (XBAP) - The simplest way to create a new XBAP project is with Visual Studio. When creating a new project, select **WPF Browser Application** from the list of templates. For more information, see [How to: Create a New WPF Browser Application Project](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/bb628663(v=vs.100)). + + The simplest way to create a new XBAP project is with Visual Studio. When creating a new project, select **WPF Browser Application** from the list of templates. For more information, see [How to: Create a New WPF Browser Application Project](/previous-versions/visualstudio/visual-studio-2010/bb628663(v=vs.100)). When you run the XBAP project, it opens in a browser window instead of a stand-alone window. When you debug the XBAP from Visual Studio, the application runs with Internet zone permission and will therefore throw security exceptions if those permissions are exceeded. For more information, see [Security](../security-wpf.md) and [WPF Partial Trust Security](../wpf-partial-trust-security.md). @@ -38,7 +41,9 @@ XAML browser applications (XBAPs) combines features of both Web applications and > If you are not developing with Visual Studio or want to learn more about the project files, see [Building a WPF Application](building-a-wpf-application-wpf.md). + ## Deploying an XBAP + When you build an XBAP, the output includes the following three files: |File|Description| @@ -75,6 +80,7 @@ XAML browser applications (XBAPs) combines features of both Web applications and ``` ### Clearing Cached XBAPs + In some situations after rebuilding and starting your XBAP, you may find that an earlier version of the XBAP is opened. For example, this behavior may occur when your XBAP assembly version number is static and you start the XBAP from the command line. In this case, because the version number between the cached version (the version that was previously started) and the new version remains the same, the new version of the XBAP is not downloaded. Instead, the cached version is loaded. In these situations, you can remove the cached version by using the **Mage** command (installed with Visual Studio or the Windows SDK) at the command prompt. The following command clears the application cache. @@ -86,13 +92,16 @@ XAML browser applications (XBAPs) combines features of both Web applications and This command guarantees that the latest version of your XBAP is started. When you debug your application in Visual Studio, the latest version of your XBAP should be started. In general, you should update your deployment version number with each build. For more information about Mage, see [Mage.exe (Manifest Generation and Editing Tool)](/dotnet/framework/tools/mage-exe-manifest-generation-and-editing-tool). + ## Communicating with the Host Web Page + When the application is hosted in an HTML frame, you can communicate with the Web page that contains the XBAP. You do this by retrieving the property of . This property returns a script object that represents the HTML window. You can then access the properties, methods, and events on the [window object](https://developer.mozilla.org/en-US/docs/Web/API/Window) by using regular dot syntax. You can also access script methods and global variables. The following example shows how to retrieve the script object and close the browser. [!code-csharp[XbapBrowserInterop#10](~/samples/snippets/csharp/VS_Snippets_Wpf/xbapbrowserinterop/cs/page1.xaml.cs#10)] [!code-vb[XbapBrowserInterop#10](~/samples/snippets/visualbasic/VS_Snippets_Wpf/xbapbrowserinterop/vb/page1.xaml.vb#10)] ### Debugging XBAPs that Use HostScript + If your XBAP uses the object to communicate with the HTML window, there are two settings that you must specify to run and debug the application in Visual Studio. The application must have access to its site of origin and you must start the application with the HTML page that contains the XBAP. The following steps describe how to check these two settings: 1. In Visual Studio, open the project properties. @@ -121,7 +130,9 @@ XAML browser applications (XBAPs) combines features of both Web applications and > Enabling active content in Internet Explorer may put your computer at risk. If you do not want to change your Internet Explorer security settings, you can launch the HTML page from a server and attach the Visual Studio debugger to the process. + ## XBAP Security Considerations + XBAPs typically execute in a partial-trust security sandbox that is restricted to the Internet zone permission set. Consequently, your implementation must support the subset of WPF elements that are supported in the Internet zone or you must elevate the permissions of your application. For more information, see [Security](../security-wpf.md). When you use a control in your application, WPF internally instantiates the native WebBrowser ActiveX control. When your application is a partial-trust XBAP running in Internet Explorer, the ActiveX control runs in a dedicated thread of the Internet Explorer process. Therefore, the following limitations apply: @@ -139,6 +150,7 @@ XAML browser applications (XBAPs) combines features of both Web applications and - does not get raised because cannot subclass a window running in another thread or process. ### Creating a Full-Trust XBAP + If your XBAP requires full trust, you can change your project to enable this permission. The following steps describe how to enable full trust: 1. In Visual Studio, open the project properties. @@ -160,6 +172,7 @@ XAML browser applications (XBAPs) combines features of both Web applications and ``` ### Deploying a Full-Trust XBAP + When you deploy a full-trust XBAP that does not follow the ClickOnce Trusted Deployment model, the behavior when the user runs the application will depend on the security zone. In some cases, the user will receive a warning when they attempt to install it. The user can choose to continue or cancel the installation. The following table describes the behavior of the application for each security zone and what you have to do for the application to receive full trust. |Security Zone|Behavior|Getting Full Trust| @@ -171,10 +184,12 @@ XAML browser applications (XBAPs) combines features of both Web applications and > [!NOTE] > The behavior described in the previous table is for full-trust XBAPs that do not follow the ClickOnce Trusted Deployment model. - It is recommended that you use the ClickOnce Trusted Deployment model for deploying a full-trust XBAP. This model allows your XBAP to be granted full trust automatically, regardless of the security zone, so that the user is not prompted. As part of this model, you must sign your application with a certificate from a trusted publisher. For more information, see [Trusted Application Deployment Overview](/visualstudio/deployment/trusted-application-deployment-overview) and [Introduction to Code Signing](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537361(v=vs.85)). + It is recommended that you use the ClickOnce Trusted Deployment model for deploying a full-trust XBAP. This model allows your XBAP to be granted full trust automatically, regardless of the security zone, so that the user is not prompted. As part of this model, you must sign your application with a certificate from a trusted publisher. For more information, see [Trusted Application Deployment Overview](/visualstudio/deployment/trusted-application-deployment-overview) and [Introduction to Code Signing](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537361(v=vs.85)). + ## XBAP Start Time Performance Considerations + An important aspect of XBAP performance is its start time. If an XBAP is the first WPF application to load, the *cold start* time can be ten seconds or more. This is because the progress page is rendered by WPF, and both the CLR and WPF must be cold-started to display the application. Starting in .NET Framework 3.5 SP1, XBAP cold-start time is mitigated by displaying an unmanaged progress page early in the deployment cycle. The progress page appears almost immediately after the application is started, because it is displayed by native hosting code and rendered in HTML. diff --git a/dotnet-desktop-guide/framework/wpf/controls/how-to-create-a-control-that-has-an-access-key-and-text-wrapping.md b/dotnet-desktop-guide/framework/wpf/controls/how-to-create-a-control-that-has-an-access-key-and-text-wrapping.md index 7fe4be9e66..645b0c17f9 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/how-to-create-a-control-that-has-an-access-key-and-text-wrapping.md +++ b/dotnet-desktop-guide/framework/wpf/controls/how-to-create-a-control-that-has-an-access-key-and-text-wrapping.md @@ -11,9 +11,11 @@ helpviewer_keywords: ms.assetid: 205099d9-2551-4302-a25e-a15af9f67e04 --- # How to: Create a Control That Has an Access Key and Text Wrapping + This example shows how to create a control that has an access key and supports text wrapping. The example uses a control to illustrate these concepts. ## Example + **Add Text Wrapping to Your Label** The control does not support text wrapping. If you need a label that wraps across multiple lines, you can nest another element that does support text wrapping and put the element inside the label. The following example shows how to use a to make a label that wraps several lines of text. @@ -32,4 +34,4 @@ This example shows how to create a control that has an access key and supports t ## See also -- [How to: Set the Target Property of a Label](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms752101(v=vs.90)) +- [How to: Set the Target Property of a Label](/previous-versions/dotnet/netframework-3.5/ms752101(v=vs.90)) diff --git a/dotnet-desktop-guide/framework/wpf/controls/how-to-crop-an-image.md b/dotnet-desktop-guide/framework/wpf/controls/how-to-crop-an-image.md index 5c6fbed218..7ac3e0bc7a 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/how-to-crop-an-image.md +++ b/dotnet-desktop-guide/framework/wpf/controls/how-to-crop-an-image.md @@ -10,11 +10,13 @@ helpviewer_keywords: ms.assetid: c6bba109-c6e7-4cf8-bfe6-9cf8d01bb4fc --- # How to: Crop an Image + This example shows how to crop an image using . - is primarily used when encoding a cropped version of an image to save out to a file. To crop an image for display purposes see the [How to: Create a Clip Region](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms746710(v=vs.90)) topic. + is primarily used when encoding a cropped version of an image to save out to a file. To crop an image for display purposes see the [How to: Create a Clip Region](/previous-versions/dotnet/netframework-3.5/ms746710(v=vs.90)) topic. ## Example + The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] defines resources used within the samples below. [!code-xaml[imageelementexample#CroppedXAML1](~/samples/snippets/csharp/VS_Snippets_Wpf/ImageElementExample/CSharp/CroppedImageExample.xaml#croppedxaml1)] @@ -35,4 +37,4 @@ This example shows how to crop an image using control that has tick marks. ## Example + The displays when you set the property to a value other than , which is the default value. The following example shows how to create a with a that displays tick marks. The and properties define the location of the tick marks and the interval between them. When you move the , tooltips display the value of the . The property defines where the tooltips occur. The movements correspond to the location of the tick marks because is set to `true`. @@ -23,4 +25,4 @@ This example shows how to create a control - - - -- [How to: Bind a Slider to a Property Value](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms788716(v=vs.90)) +- [How to: Bind a Slider to a Property Value](/previous-versions/dotnet/netframework-3.5/ms788716(v=vs.90)) diff --git a/dotnet-desktop-guide/framework/wpf/controls/how-to-define-a-groupbox-template.md b/dotnet-desktop-guide/framework/wpf/controls/how-to-define-a-groupbox-template.md index 50c7f796e0..a2796e6d49 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/how-to-define-a-groupbox-template.md +++ b/dotnet-desktop-guide/framework/wpf/controls/how-to-define-a-groupbox-template.md @@ -7,9 +7,11 @@ helpviewer_keywords: ms.assetid: 85a4d1a7-4753-4f4a-b26d-14fa10c1ddb5 --- # How to: Define a GroupBox Template + This example shows how to create a template for a control. ## Example + The following example defines a control template by using a control for layout. The template uses a to define the border of the so that the border does not obscure the content. [!code-xaml[GroupBoxSnippet#GroupBoxTemplate](~/samples/snippets/csharp/VS_Snippets_Wpf/GroupBoxSnippet/CS/Window1.xaml#groupboxtemplate)] @@ -17,4 +19,4 @@ This example shows how to create a template for a -- [How to: Create a GroupBox](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms748321(v=vs.90)) +- [How to: Create a GroupBox](/previous-versions/dotnet/netframework-3.5/ms748321(v=vs.90)) diff --git a/dotnet-desktop-guide/framework/wpf/controls/label.md b/dotnet-desktop-guide/framework/wpf/controls/label.md index 6bf0b549bc..1d5449bae7 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/label.md +++ b/dotnet-desktop-guide/framework/wpf/controls/label.md @@ -9,16 +9,19 @@ helpviewer_keywords: ms.assetid: 241c1ce2-60f8-4613-a0ec-9b9bb25fb6af --- # Label + controls usually provide information in the [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)]. Historically, a has contained only text, but because the that ships with [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] is a , it can contain either text or a . A provides both functional and visual support for access keys. It is frequently used to enable quick keyboard access to controls such as a . To assign a to a , set the property to the control that should get focus when the user presses the access key. - The following image shows a "Themes" that targets a . When the user presses , the receives focus. For more information, see [How to: Set the Target Property of a Label](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms752101(v=vs.90)). + The following image shows a "Themes" that targets a . When the user presses , the receives focus. For more information, see [How to: Set the Target Property of a Label](/previous-versions/dotnet/netframework-3.5/ms752101(v=vs.90)). ![Screenshot of Display Properties dialog showing labeled by usage.](./media/label/display-properties-labeled-by.png "LabeledBy") ## In This Section + [How to: Create a Control That Has an Access Key and Text Wrapping](how-to-create-a-control-that-has-an-access-key-and-text-wrapping.md) ## Reference + diff --git a/dotnet-desktop-guide/framework/wpf/controls/listbox-how-to-topics.md b/dotnet-desktop-guide/framework/wpf/controls/listbox-how-to-topics.md index 17e54129ab..2833118588 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/listbox-how-to-topics.md +++ b/dotnet-desktop-guide/framework/wpf/controls/listbox-how-to-topics.md @@ -9,15 +9,18 @@ helpviewer_keywords: ms.assetid: 15d58f1d-3db6-4cb5-88c7-8c45f19301e2 --- # ListBox How-to Topics + The topics in this section describe how to use the control to display selectable lists of items. ## In This Section + [Bind a ListBox to Data](how-to-bind-a-listbox-to-data.md) [Get a ListBoxItem](how-to-get-a-listboxitem.md) - [How to: Add Data to an ItemsControl](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms743602(v=vs.90)) + [How to: Add Data to an ItemsControl](/previous-versions/dotnet/netframework-3.5/ms743602(v=vs.90)) [Improve the Scrolling Performance of a ListBox](how-to-improve-the-scrolling-performance-of-a-listbox.md) ## Reference + diff --git a/dotnet-desktop-guide/framework/wpf/controls/panels-overview.md b/dotnet-desktop-guide/framework/wpf/controls/panels-overview.md index 6331814c53..3d5f6e9646 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/panels-overview.md +++ b/dotnet-desktop-guide/framework/wpf/controls/panels-overview.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 --- # Panels Overview + elements are components that control the rendering of elements—their size and dimensions, their position, and the arrangement of their child content. The [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] provides a number of predefined elements as well as the ability to construct custom elements. This topic contains the following sections. @@ -31,13 +32,17 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 - [Localization/Globalization Support](#Panels_global_localization) + ## The Panel Class + is the base class for all elements that provide layout support in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)]. Derived elements are used to position and arrange elements in [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] and code. The [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] includes a comprehensive suite of derived panel implementations that enable many complex layouts. These derived classes expose properties and methods that enable most standard [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)] scenarios. Developers who are unable to find a child arrangement behavior that meets their needs can create new layouts by overriding the and methods. For more information on custom layout behaviors, see [Custom Panel Elements](#Panels_custom_panel_elements). + ## Panel Common Members + All elements support the base sizing and positioning properties defined by , including , , , , , and . For additional information on positioning properties defined by , see [Alignment, Margins, and Padding Overview](../advanced/alignment-margins-and-padding-overview.md). exposes additional properties that are of critical importance in understanding and using layout. The property is used to fill the area between the boundaries of a derived panel element with a . represents the child collection of elements that the is comprised of. represents the content of the collection plus those members generated by data binding. Both consist of a of child elements hosted within the parent . @@ -47,12 +52,15 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 also defines the method, which can be used to override the default presentation behavior of a . #### Attached Properties + Derived panel elements make extensive use of attached properties. An attached property is a specialized form of dependency property that does not have the conventional common language runtime (CLR) property "wrapper". Attached properties have a specialized syntax in [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)], which can be seen in several of the examples that follow. One purpose of an attached property is to allow child elements to store unique values of a property that is actually defined by a parent element. An application of this functionality is having child elements inform the parent how they wish to be presented in the [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)], which is extremely useful for application layout. For more information, see [Attached Properties Overview](../advanced/attached-properties-overview.md). + ## Derived Panel Elements + Many objects derive from , but not all of them are intended for use as root layout providers. There are six defined panel classes (, , , , , and ) that are designed specifically for creating application [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)]. Each panel element encapsulates its own special functionality, as seen in the following table. @@ -71,7 +79,9 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 ||Yes| positions child elements in sequential position from left to right, breaking content to the next line at the edge of the containing box. Subsequent ordering happens sequentially from top to bottom or right to left, depending on the value of the property.| + ## User Interface Panels + There are six panel classes available in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] that are optimized to support [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] scenarios: , , , , , and . These panel elements are easy to use, versatile, and extensible enough for most applications. Each derived element treats sizing constraints differently. Understanding how a handles constraints in either the horizontal or vertical direction can make layout more predictable. @@ -88,17 +98,21 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 More detailed descriptions and usage examples of each of these elements can be found below. + ### Canvas + The element enables positioning of content according to absolute *x-* and *y-* coordinates. Elements can be drawn in a unique location; or, if elements occupy the same coordinates, the order in which they appear in markup determines the order in which the elements are drawn. provides the most flexible layout support of any . Height and Width properties are used to define the area of the canvas, and elements inside are assigned absolute coordinates relative to the area of the parent . Four attached properties, , , and , allow fine control of object placement within a , allowing the developer to position and arrange elements precisely on the screen. #### ClipToBounds Within a Canvas + can position child elements at any position on the screen, even at coordinates that are outside of its own defined and . Furthermore, is not affected by the size of its children. As a result, it is possible for a child element to overdraw other elements outside the bounding rectangle of the parent . The default behavior of a is to allow children to be drawn outside the bounds of the parent . If this behavior is undesirable, the property can be set to `true`. This causes to clip to its own size. is the only layout element that allows children to be drawn outside its bounds. This behavior is graphically illustrated in the [Width Properties Comparison Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Elements/WidthProperties). #### Defining and Using a Canvas + A can be instantiated simply by using [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] or code. The following example demonstrates how to use to absolutely position content. This code produces three 100-pixel squares. The first square is red, and its top-left (*x, y*) position is specified as (0, 0). The second square is green, and its top-left position is (100, 100), just below and to the right of the first square. The third square is blue, and its top-left position is (50, 50), thus encompassing the lower-right quadrant of the first square and the upper-left quadrant of the second. Because the third square is laid out last, it appears to be on top of the other two squares—that is, the overlapping portions assume the color of the third box. [!code-csharp[CanvasOvwSample#1](~/samples/snippets/csharp/VS_Snippets_Wpf/CanvasOvwSample/CSharp/Canvas_Ovw_Sample.cs#1)] @@ -110,18 +124,23 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 ![A typical Canvas Element.](./media/panel-intro-canvas.PNG "panel_intro_canvas") + ### DockPanel + The element uses the attached property as set in child content elements to position content along the edges of a container. When is set to or , it positions child elements above or below each other. When is set to or , it positions child elements to the left or right of each other. The property determines the position of the final element added as a child of a . You can use to position a group of related controls, such as a set of buttons. Alternately, you can use it to create a "paned" [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)], similar to that found in Microsoft Outlook. #### Sizing to Content + If its and properties are not specified, sizes to its content. The size can increase or decrease to accommodate the size of its child elements. However, when these properties are specified and there is no longer room for the next specified child element, does not display that child element or subsequent child elements and does not measure subsequent child elements. #### LastChildFill + By default, the last child of a element will "fill" the remaining, unallocated space. If this behavior is not desired, set the property to `false`. #### Defining and Using a DockPanel + The following example demonstrates how to partition space using a . Five elements are added as children of a parent . Each uses a different positioning property of a to partition space. The final element "fills" the remaining, unallocated space. [!code-cpp[DockPanelOvwSample#1](~/samples/snippets/cpp/VS_Snippets_Wpf/DockPanelOvwSample/CPP/DockPanel_Ovw_Sample.cpp#1)] @@ -134,16 +153,21 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 ![A typical DockPanel scenario.](./media/panel-intro-dockpanel.PNG "panel_intro_dockpanel") + ### Grid + The element merges the functionality of an absolute positioning and tabular data control. A enables you to easily position and style elements. allows you to define flexible row and column groupings, and even provides a mechanism to share sizing information between multiple elements. -#### How is Grid Different from Table? +#### How is Grid Different from Table + and share some common functionality, but each is best suited for different scenarios. A is designed for use within flow content (see [Flow Document Overview](../advanced/flow-document-overview.md) for more information on flow content). Grids are best used inside of forms (basically anywhere outside of flow content). Within a , supports flow content behaviors like pagination, column reflow, and content selection while a does not. A on the other hand is best used outside of a for many reasons including adds elements based on a row and column index, does not. The element allows layering of child content, allowing more than one element to exist within a single "cell." does not support layering. Child elements of a can be absolutely positioned relative to the area of their "cell" boundaries. does not support this feature. Finally, a is lighter weight than a . #### Sizing Behavior of Columns and Rows + Columns and rows defined within a can take advantage of sizing in order to distribute remaining space proportionally. When is selected as the Height or Width of a row or column, that column or row receives a weighted proportion of remaining available space. This is in contrast to , which will distribute space evenly based on the size of the content within a column or row. This value is expressed as `*` or `2*` when using [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)]. In the first case, the row or column would receive one times the available space, in the second case, two times, and so on. By combining this technique to proportionally distribute space with a and value of `Stretch` it is possible to partition layout space by percentage of screen space. is the only layout panel that can distribute space in this manner. #### Defining and Using a Grid + The following example demonstrates how to build a [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] similar to that found on the Run dialog available on the Windows Start menu. [!code-csharp[GridRunDialog#1](~/samples/snippets/csharp/VS_Snippets_Wpf/GridRunDialog/CSharp/window1.xaml.cs#1)] @@ -154,10 +178,13 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 ![A typical Grid Element.](./media/avalon-run-dialog.PNG "avalon_run_dialog") + ### StackPanel + A enables you to "stack" elements in an assigned direction. The default stack direction is vertical. The property can be used to control content flow. #### StackPanel vs. DockPanel + Although can also "stack" child elements, and do not produce analogous results in some usage scenarios. For example, the order of child elements can affect their size in a but not in a . This is because measures in the direction of stacking at , whereas measures only the available size. The following example demonstrates this key difference. @@ -172,6 +199,7 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 ![Screenshot: StackPanel vs. DockPanel screenshot](./media/layout-smiley-stackpanel.PNG "layout_smiley_stackpanel") #### Defining and Using a StackPanel + The following example demonstrates how to use a to create a set of vertically-positioned buttons. For horizontal positioning, set the property to . [!code-csharp[StackPanel_ovw2#1](~/samples/snippets/csharp/VS_Snippets_Wpf/StackPanel_ovw2/CSharp/StackPanel_Ovw_Sample2.cs#1)] @@ -182,7 +210,9 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 ![A typical StackPanel element.](./media/panel-intro-stackpanel.PNG "panel_intro_stackpanel") + #### VirtualizingStackPanel + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] also provides a variation of the element that automatically "virtualizes" data-bound child content. In this context, the word virtualize refers to a technique by which a subset of elements are generated from a larger number of data items based upon which items are visible on-screen. It is intensive, both in terms of memory and processor, to generate a large number of UI elements when only a few may be on the screen at a given time. (through functionality provided by ) calculates visible items and works with the from an (such as or ) to only create elements for visible items. The element is automatically set as the items host for controls such as the . When hosting a data bound collection, content is automatically virtualized, as long as the content is within the bounds of a . This greatly improves performance when hosting many child items. @@ -192,7 +222,9 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 [!code-xaml[VirtualizingStackPanel_Intro#1](~/samples/snippets/csharp/VS_Snippets_Wpf/VirtualizingStackPanel_Intro/CS/default.xaml#1)] + ### WrapPanel + is used to position child elements in sequential position from left to right, breaking content to the next line when it reaches the edge of its parent container. Content can be oriented horizontally or vertically. is useful for simple flowing [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)] scenarios. It can also be used to apply uniform sizing to all of its child elements. The following example demonstrates how to create a to display controls that wrap when they reach the edge of their container. @@ -207,7 +239,9 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 ![A typical WrapPanel Element.](./media/wrappanel-element.PNG "WrapPanel_Element") + ## Nested Panel Elements + elements can be nested within each other in order to produce complex layouts. This can prove very useful in situations where one is ideal for a portion of a [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)], but may not meet the needs of a different portion of the [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)]. There is no practical limit to the amount of nesting that your application can support, however, it is generally best to limit your application to only use those panels that are actually necessary for your desired layout. In many cases, a element can be used instead of nested panels due to its flexibility as a layout container. This can increase performance in your application by keeping unnecessary elements out of the tree. @@ -222,7 +256,9 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 ![A UI that takes advantage of nested panels.](./media/nested-panels.PNG "nested_panels") + ## Custom Panel Elements + While [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] provides an array of flexible layout controls, custom layout behaviors can also be achieved by overriding the and methods. Custom sizing and positioning can be accomplished by defining new positioning behaviors within these override methods. Similarly, custom layout behaviors based on derived classes (such as or ) can be defined by overriding their and methods. @@ -233,10 +269,12 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 [!code-csharp[PlotPanel#1](~/samples/snippets/csharp/VS_Snippets_Wpf/PlotPanel/CSharp/PlotPanel.cs#1)] [!code-vb[PlotPanel#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/PlotPanel/VisualBasic/PlotPanel.vb#1)] - To view a more complex custom panel implementation, see [Create a Custom Content-Wrapping Panel Sample](https://go.microsoft.com/fwlink/?LinkID=159979). + To view a more complex custom panel implementation, see [Create a Custom Content-Wrapping Panel Sample](/samples/browse/). + ## Localization/Globalization Support + [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] supports a number of features that assist in the creation of localizable [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)]. All panel elements natively support the property, which can be used to dynamically re-flow content based on a user's locale or language settings. For more information, see . @@ -250,11 +288,11 @@ ms.assetid: f73644af-9941-4611-8754-6d4cef03fc44 ## See also - [Walkthrough: My first WPF desktop application](../getting-started/walkthrough-my-first-wpf-desktop-application.md) -- [WPF Layout Gallery Sample](https://go.microsoft.com/fwlink/?LinkID=160054) +- [WPF Layout Gallery Sample](/samples/browse/) - [Layout](../advanced/layout.md) - [WPF Controls Gallery Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Getting%20Started/ControlsAndLayout) - [Alignment, Margins, and Padding Overview](../advanced/alignment-margins-and-padding-overview.md) -- [Create a Custom Content-Wrapping Panel Sample](https://go.microsoft.com/fwlink/?LinkID=159979) +- [Create a Custom Content-Wrapping Panel Sample](/samples/browse/) - [Attached Properties Overview](../advanced/attached-properties-overview.md) - [Use Automatic Layout Overview](../advanced/use-automatic-layout-overview.md) - [Layout and Design](../advanced/optimizing-performance-layout-and-design.md) diff --git a/dotnet-desktop-guide/framework/wpf/controls/scrollviewer-overview.md b/dotnet-desktop-guide/framework/wpf/controls/scrollviewer-overview.md index 7d072018b0..946b8a46d5 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/scrollviewer-overview.md +++ b/dotnet-desktop-guide/framework/wpf/controls/scrollviewer-overview.md @@ -12,10 +12,13 @@ helpviewer_keywords: ms.assetid: 94a13b94-cfdf-4b12-a1aa-90cb50c6e9b9 --- # ScrollViewer Overview + Content within a user interface is often larger than a computer screen's display area. The control provides a convenient way to enable scrolling of content in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] applications. This topic introduces the element and provides several usage examples. + ## The ScrollViewer Control + There are two predefined elements that enable scrolling in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications: and . The control encapsulates horizontal and vertical elements and a content container (such as a element) in order to display other visible elements in a scrollable area. You must build a custom object in order to use the element for content scrolling. However, you can use the element by itself because it is a composite control that encapsulates functionality. The control responds to both mouse and keyboard commands, and defines numerous methods with which to scroll content by predetermined increments. You can use the event to detect a change in a state. @@ -23,10 +26,13 @@ Content within a user interface is often larger than a computer screen's display A can only have one child, typically a element that can host a collection of elements. The property defines the sole child of the . + ## Physical vs. Logical Scrolling + Physical scrolling is used to scroll content by a predetermined physical increment, typically by a value that is declared in pixels. Logical scrolling is used to scroll to the next item in the logical tree. Physical scrolling is the default scroll behavior for most elements. [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] supports both types of scrolling. #### The IScrollInfo Interface + The interface represents the main scrolling region within a or derived control. The interface defines scrolling properties and methods that can be implemented by elements that require scrolling by logical unit, rather than by a physical increment. Casting an instance of to a derived and then using its scrolling methods provides a useful way to scroll to the next logical unit in a child collection, rather than by pixel increment. By default, the control supports scrolling by physical units. and both implement and natively support logical scrolling. For layout controls that natively support logical scrolling, you can still achieve physical scrolling by wrapping the host element in a and setting the property to `false`. @@ -37,7 +43,9 @@ Content within a user interface is often larger than a computer screen's display [!code-vb[IScrollInfoMethods#3](~/samples/snippets/visualbasic/VS_Snippets_Wpf/IScrollInfoMethods/VisualBasic/Window1.xaml.vb#3)] + ## Defining and Using a ScrollViewer Element + The following example creates a in a window that contains some text and a rectangle. elements appear only when they are necessary. When you resize the window, the elements appear and disappear, due to updated values of the and properties. [!code-cpp[ScrollViewer#1](~/samples/snippets/cpp/VS_Snippets_Wpf/ScrollViewer/CPP/ScrollViewer_wcp.cpp#1)] @@ -46,11 +54,15 @@ Content within a user interface is often larger than a computer screen's display [!code-xaml[ScrollViewer#1](~/samples/snippets/xaml/VS_Snippets_Wpf/ScrollViewer/XAML/Pane1.xaml#1)] + ## Styling a ScrollViewer + Like all controls in Windows Presentation Foundation, the can be styled in order to change the default rendering behavior of the control. For additional information on control styling, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview). + ## Paginating Documents + For document content, an alternative to scrolling is to choose a document container that supports pagination. is for documents that are designed to be hosted within a viewing control, such as , that supports paginating content across multiple pages, preventing the need for scrolling. provides a solution for viewing content, which uses traditional scrolling to display content outside the realm of the display area. For additional information about document formats and presentation options, see [Documents in WPF](../advanced/documents-in-wpf.md). @@ -60,7 +72,7 @@ Content within a user interface is often larger than a computer screen's display - - - -- [How to: Create a Scroll Viewer](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms752352(v=vs.90)) +- [How to: Create a Scroll Viewer](/previous-versions/dotnet/netframework-3.5/ms752352(v=vs.90)) - [Documents in WPF](../advanced/documents-in-wpf.md) - [ScrollBar Styles and Templates](scrollbar-styles-and-templates.md) - [Controls](../advanced/optimizing-performance-controls.md) diff --git a/dotnet-desktop-guide/framework/wpf/controls/tooltip-overview.md b/dotnet-desktop-guide/framework/wpf/controls/tooltip-overview.md index b2b936f1e8..54567d1ec7 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/tooltip-overview.md +++ b/dotnet-desktop-guide/framework/wpf/controls/tooltip-overview.md @@ -10,10 +10,13 @@ helpviewer_keywords: ms.assetid: f06c1603-e9cb-4809-8a62-234607fc52f7 --- # ToolTip Overview + A tooltip is a small pop-up window that appears when a user pauses the mouse pointer over an element, such as over a . This topic introduces the tooltip and discusses how to create and customize tooltip content. -## What Is a Tooltip? + +## What Is a Tooltip + When a user moves the mouse pointer over an element that has a tooltip, a window that contains tooltip content (for example, text content that describes the function of a control) appears for a specified amount of time. If the user moves the mouse pointer away from the control, the window disappears because the tooltip content cannot receive focus. The content of a tooltip can contain one or more lines of text, images, shapes, or other visual content. You define a tooltip for a control by setting one of the following properties to the tooltip content. @@ -25,7 +28,9 @@ A tooltip is a small pop-up window that appears when a user pauses the mouse poi Which property you use depends on whether the control that defines the tooltip inherits from the or class. + ## Creating a ToolTip + The following example shows how to create a simple tooltip by setting the property for a control to a text string. [!code-xaml[GroupBoxSnippet#ToolTipString](~/samples/snippets/csharp/VS_Snippets_Wpf/GroupBoxSnippet/CS/Window1.xaml#tooltipstring)] @@ -44,22 +49,28 @@ A tooltip is a small pop-up window that appears when a user pauses the mouse poi [!code-xaml[GroupBoxSnippet#ToolTipDockPanel](~/samples/snippets/csharp/VS_Snippets_Wpf/GroupBoxSnippet/CS/Window1.xaml#tooltipdockpanel)] + ## Using the Properties of the ToolTip and ToolTipService Classes + You can customize tooltip content by setting visual properties and applying styles. If you define the tooltip content as a object, you can set the visual properties of the object. Otherwise, you must set equivalent attached properties on the class. For an example of how to set properties in order to specify the position of tooltip content by using the and properties, see [Position a ToolTip](how-to-position-a-tooltip.md). + ## Styling a ToolTip + You can style a by defining a custom . The following example defines a called `Simple` that shows how to offset the placement of the and change its appearance by setting the , , , and . [!code-xaml[ToolTipSimple#Style](~/samples/snippets/csharp/VS_Snippets_Wpf/ToolTipSimple/CSharp/Pane1.xaml#style)] + ## Using the Time Interval Properties of ToolTipService + The class provides the following properties for you to set tooltip display times: , , and . - Use the and properties to specify a delay, typically brief, before a appears and also to specify how long a remains visible. For more information, see [How to: Delay the Display of a ToolTip](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms747264(v=vs.90)). + Use the and properties to specify a delay, typically brief, before a appears and also to specify how long a remains visible. For more information, see [How to: Delay the Display of a ToolTip](/previous-versions/dotnet/netframework-3.5/ms747264(v=vs.90)). The property determines if tooltips for different controls appear without an initial delay when you move the mouse pointer quickly between them. For more information about the property, see [Use the BetweenShowDelay Property](how-to-use-the-betweenshowdelay-property.md). diff --git a/dotnet-desktop-guide/framework/wpf/controls/walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control.md b/dotnet-desktop-guide/framework/wpf/controls/walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control.md index 4909c4d741..7d62ee64a2 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control.md +++ b/dotnet-desktop-guide/framework/wpf/controls/walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control.md @@ -40,7 +40,7 @@ You need the following components to complete this walkthrough: 5. In the Choose Model Contents screen, select **EF Designer from database** and then click **Next**. -6. In the Choose Your Data Connection screen, provide the connection to your AdventureWorksLT2008 database. For more information, see [Choose Your Data Connection Dialog Box](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb399244(v=vs.100)). +6. In the Choose Your Data Connection screen, provide the connection to your AdventureWorksLT2008 database. For more information, see [Choose Your Data Connection Dialog Box](/previous-versions/dotnet/netframework-4.0/bb399244(v=vs.100)). Make sure that the name is `AdventureWorksLT2008Entities` and that the **Save entity connection settings in App.Config as** check box is selected, and then click **Next**. @@ -70,7 +70,7 @@ You need the following components to complete this walkthrough: 4. Select the . -5. Using the Properties window or XAML editor, create an event handler for the named `Window_Loaded` for the event. For more information, see [How to: Create a Simple Event Handler](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/bb675300(v=vs.100)). +5. Using the Properties window or XAML editor, create an event handler for the named `Window_Loaded` for the event. For more information, see [How to: Create a Simple Event Handler](/previous-versions/visualstudio/visual-studio-2010/bb675300(v=vs.100)). The following shows the XAML for MainWindow.xaml. diff --git a/dotnet-desktop-guide/framework/wpf/data/how-to-create-a-binding-in-code.md b/dotnet-desktop-guide/framework/wpf/data/how-to-create-a-binding-in-code.md index bce25a79d8..a34a295b31 100644 --- a/dotnet-desktop-guide/framework/wpf/data/how-to-create-a-binding-in-code.md +++ b/dotnet-desktop-guide/framework/wpf/data/how-to-create-a-binding-in-code.md @@ -11,9 +11,11 @@ helpviewer_keywords: ms.assetid: 1a606db9-cf5f-42ed-a1c5-9e4722ec77a0 --- # How to: Create a Binding in Code + This example shows how to create and set a in code. ## Example + The class and the class both expose a `SetBinding` method. If you are binding an element that inherits either of these classes, you can call the method directly. The following example creates a class named, `MyData`, which contains a property named `MyDataProperty`. @@ -26,7 +28,7 @@ This example shows how to create and set a in [!code-csharp[CodeOnlyBinding#1](~/samples/snippets/csharp/VS_Snippets_Wpf/CodeOnlyBinding/CSharp/binding.cs#1)] [!code-vb[CodeOnlyBinding#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/CodeOnlyBinding/VisualBasic/App.vb#1)] - For the complete code sample, see [Code-only Binding Sample](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms771500(v=vs.90)). + For the complete code sample, see [Code-only Binding Sample](/previous-versions/dotnet/netframework-3.5/ms771500(v=vs.90)). Instead of calling , you can use the static method of the class. The following example, calls instead of to bind `myText` to `myDataProperty`. diff --git a/dotnet-desktop-guide/framework/wpf/data/how-to-implement-prioritybinding.md b/dotnet-desktop-guide/framework/wpf/data/how-to-implement-prioritybinding.md index 8eda370490..97e7a72ae8 100644 --- a/dotnet-desktop-guide/framework/wpf/data/how-to-implement-prioritybinding.md +++ b/dotnet-desktop-guide/framework/wpf/data/how-to-implement-prioritybinding.md @@ -9,9 +9,11 @@ helpviewer_keywords: ms.assetid: d63b65ab-b3e9-4322-9aa8-1450f8d89532 --- # How to: Implement PriorityBinding + in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] works by specifying a list of bindings. The list of bindings is ordered from highest priority to lowest priority. If the highest priority binding returns a value successfully when it is processed then there is never a need to process the other bindings in the list. It could be the case that the highest priority binding takes a long time to be evaluated, the next highest priority that returns a value successfully will be used until a binding of a higher priority returns a value successfully. ## Example + To demonstrate how works, the `AsyncDataSource` object has been created with the following three properties: `FastDP`, `SlowerDP`, and `SlowestDP`. The get accessor of `FastDP` returns the value of the `_fastDP` data member. @@ -21,7 +23,7 @@ ms.assetid: d63b65ab-b3e9-4322-9aa8-1450f8d89532 The get accessor of `SlowestDP` waits for 5 seconds before returning the value of the `_slowestDP` data member. > [!NOTE] -> This example is for demonstration purposes only. The .NET guidelines recommend against defining properties that are orders of magnitude slower than a field set would be. For more information, see [Choosing Between Properties and Methods](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms229054(v=vs.100)). +> This example is for demonstration purposes only. The .NET guidelines recommend against defining properties that are orders of magnitude slower than a field set would be. For more information, see [Choosing Between Properties and Methods](/previous-versions/dotnet/netframework-4.0/ms229054(v=vs.100)). [!code-csharp[PriorityBinding#1](~/samples/snippets/csharp/VS_Snippets_Wpf/PriorityBinding/CSharp/Window1.xaml.cs#1)] [!code-vb[PriorityBinding#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/PriorityBinding/VisualBasic/AsyncDataSource.vb#1)] diff --git a/dotnet-desktop-guide/framework/wpf/data/wpf-data-binding-with-linq-to-xml-overview.md b/dotnet-desktop-guide/framework/wpf/data/wpf-data-binding-with-linq-to-xml-overview.md index 2e2ade2b1e..62c3e9c0fd 100644 --- a/dotnet-desktop-guide/framework/wpf/data/wpf-data-binding-with-linq-to-xml-overview.md +++ b/dotnet-desktop-guide/framework/wpf/data/wpf-data-binding-with-linq-to-xml-overview.md @@ -85,4 +85,4 @@ To implement WPF dynamic binding, dynamic properties will be used with facilitie - [LINQ to XML Dynamic Properties](linq-to-xml-dynamic-properties.md) - [XAML in WPF](../advanced/xaml-in-wpf.md) - [Data Binding (WPF)](/dotnet/framework/wpf/data/data-binding-wpf) -- [Using Workflow Markup](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms735921(v=vs.90)) +- [Using Workflow Markup](/previous-versions/dotnet/netframework-3.5/ms735921(v=vs.90)) diff --git a/dotnet-desktop-guide/framework/wpf/getting-started/walkthrough-my-first-wpf-desktop-application.md b/dotnet-desktop-guide/framework/wpf/getting-started/walkthrough-my-first-wpf-desktop-application.md index 2c4daa72a2..f1d8f9f48f 100644 --- a/dotnet-desktop-guide/framework/wpf/getting-started/walkthrough-my-first-wpf-desktop-application.md +++ b/dotnet-desktop-guide/framework/wpf/getting-started/walkthrough-my-first-wpf-desktop-application.md @@ -318,7 +318,7 @@ The following illustration shows the results of what you just added: ## Add code to handle events -1. In *`ExpenseItHome.xaml`*, add a event handler to the element. For more information, see [How to: Create a simple event handler](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/bb675300(v=vs.100)). +1. In *`ExpenseItHome.xaml`*, add a event handler to the element. For more information, see [How to: Create a simple event handler](/previous-versions/visualstudio/visual-studio-2010/bb675300(v=vs.100)). [!code-xaml[ExpenseIt#15](~/samples/snippets/csharp/VS_Snippets_Wpf/ExpenseIt/CSharp/ExpenseIt6/ExpenseItHome.xaml#15)] diff --git a/dotnet-desktop-guide/framework/wpf/getting-started/wpf-walkthroughs.md b/dotnet-desktop-guide/framework/wpf/getting-started/wpf-walkthroughs.md index 0bcc670727..3265eee7d9 100644 --- a/dotnet-desktop-guide/framework/wpf/getting-started/wpf-walkthroughs.md +++ b/dotnet-desktop-guide/framework/wpf/getting-started/wpf-walkthroughs.md @@ -8,6 +8,7 @@ helpviewer_keywords: ms.assetid: c29bde96-0389-4aff-a9fb-cd678f66b7f7 --- # WPF Walkthroughs + Walkthroughs give step-by-step instructions for common scenarios. This makes them a good place to start learning about the product or a particular feature area. This topic contains links to Windows Presentation Foundation (WPF) walkthroughs. @@ -16,11 +17,11 @@ Walkthroughs give step-by-step instructions for common scenarios. This makes the |Title|Description| |-----------|-----------------| -|[Walkthrough: Building a Simple WPF Application with the WPF Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/bb546972(v=vs.100))|Demonstrates how to build a simple WPF application with the WPF Designer.| -|[Walkthrough: Constructing a Dynamic Layout](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/bb514519(v=vs.100))|Demonstrates creating a dynamic layout by using a panel control.| -|[Walkthrough: Creating a Resizable Application by Using the WPF Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/bb546954(v=vs.100))|Demonstrates how to create window layouts that are resizable by the user at run time.| -|[Walkthrough: Creating a Data Binding by Using the WPF Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/dd434207(v=vs.100))|Demonstrates how to use the WPF Designer to create data bindings that connect data to a control.| -|[Walkthrough: Using a DesignInstance to Bind to Data in the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/dd490796(v=vs.100))|Demonstrates how to use the WPF Designer to create data bindings at design time for a data context that is assigned at run time.| +|[Walkthrough: Building a Simple WPF Application with the WPF Designer](/previous-versions/visualstudio/visual-studio-2010/bb546972(v=vs.100))|Demonstrates how to build a simple WPF application with the WPF Designer.| +|[Walkthrough: Constructing a Dynamic Layout](/previous-versions/visualstudio/visual-studio-2010/bb514519(v=vs.100))|Demonstrates creating a dynamic layout by using a panel control.| +|[Walkthrough: Creating a Resizable Application by Using the WPF Designer](/previous-versions/visualstudio/visual-studio-2010/bb546954(v=vs.100))|Demonstrates how to create window layouts that are resizable by the user at run time.| +|[Walkthrough: Creating a Data Binding by Using the WPF Designer](/previous-versions/visualstudio/visual-studio-2010/dd434207(v=vs.100))|Demonstrates how to use the WPF Designer to create data bindings that connect data to a control.| +|[Walkthrough: Using a DesignInstance to Bind to Data in the Designer](/previous-versions/visualstudio/visual-studio-2010/dd490796(v=vs.100))|Demonstrates how to use the WPF Designer to create data bindings at design time for a data context that is assigned at run time.| ## WPF Walkthroughs @@ -45,4 +46,4 @@ Walkthroughs give step-by-step instructions for common scenarios. This makes the |Title|Description| |-----------|-----------------| -|[Visual Studio Walkthroughs](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/szatc41e(v=vs.100))|Gives a related list of walkthroughs for all areas of programming in Visual Studio.| +|[Visual Studio Walkthroughs](/previous-versions/visualstudio/visual-studio-2010/szatc41e(v=vs.100))|Gives a related list of walkthroughs for all areas of programming in Visual Studio.| diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/animation-tips-and-tricks.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/animation-tips-and-tricks.md index 293418dffe..c0d6ac8154 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/animation-tips-and-tricks.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/animation-tips-and-tricks.md @@ -16,21 +16,27 @@ helpviewer_keywords: ms.assetid: e467796b-d5d4-45a6-a108-8c5d7ff69a0f --- # Animation Tips and Tricks + When working with animations in WPF, there are a number of tips and tricks that can make your animations perform better and save you frustration. + ## General Issues ### Animating the Position of a Scroll Bar or Slider Freezes It + If you animate the position of a scroll bar or slider using an animation that has a of (the default value), the user will no longer be able to move the scroll bar or slider. That's because, even though the animation ended, it's still overriding the target property's base value. To stop the animation from overriding the property's current value, remove it, or give it a of . For more information and an example, see [Set a Property After Animating It with a Storyboard](how-to-set-a-property-after-animating-it-with-a-storyboard.md). ### Animating the Output of an Animation Has No Effect + You can't animate an object that is the output of another animation. For example, if you use an to animate the of a from a to a , you can't animate any properties of the or . ### Can't Change the Value of a Property after Animating it + In some cases, it might appear that you can't change the value of a property after it's been animated, even after the animation has ended. That's because, even though the animation ended, it's still overriding the property's base value. To stop the animation from overriding the property's current value, remove it, or give it a of . For more information and an example, see [Set a Property After Animating It with a Storyboard](how-to-set-a-property-after-animating-it-with-a-storyboard.md). ### Changing a Timeline Has No Effect + Although most properties are animatable and can be data bound, changing the property values of an active seems to have no effect. That's because, when a is begun, the timing system makes a copy of the and uses it to create a object. Modifying the original has no effect on the system's copy. For a to reflect changes, its clock must be regenerated and used to replace the previously created clock. Clocks are not regenerated for you automatically. The following are several ways to apply timeline changes: @@ -44,6 +50,7 @@ When working with animations in WPF, there are a number of tips and tricks that For more information about timelines and clocks, see [Animation and Timing System Overview](animation-and-timing-system-overview.md). ### FillBehavior.Stop Doesn't Work as Expected + There are times when setting the property to seems to have no effect, such as when one animation "hands off" to another because it has a setting of . The following example creates a , a and a . The will be animated to move the around the . @@ -53,6 +60,7 @@ When working with animations in WPF, there are a number of tips and tricks that The examples in this section use the preceding objects to demonstrate several cases where the property doesn't behave as you might expect it to. #### FillBehavior="Stop" and HandoffBehavior with Multiple Animations + Sometimes it seems as though an animation ignores its property when it is replaced by a second animation. Take the following example, which creates two objects and uses them to animate the same shown in the preceding example. The first , `B1`, animates the property of the from 0 to 350, which moves the rectangle 350 pixels to the right. When the animation reaches the end of its duration and stops playing, the property reverts to its original value, 0. As a result, the rectangle moves to the right 350 pixels and then jumps back to its original position. @@ -72,6 +80,7 @@ When working with animations in WPF, there are a number of tips and tricks that **But that's not what happens.** Instead, the rectangle does not jump back; it continues moving to the right. That's because the second animation uses the current value of the first animation as its starting value and animates from that value to 500. When the second animation replaces the first because the is used, the of the first animation does not matter. #### FillBehavior and the Completed Event + The next examples demonstrate another scenario in which the seems to have no effect. Again, the example uses a Storyboard to animate the property of the from 0 to 350. However, this time the example registers for the event. [!code-xaml[AnimationTipsAndTricksSample_snip#FillBehaviorTipStoryboardCButton](~/samples/snippets/csharp/VS_Snippets_Wpf/AnimationTipsAndTricksSample_snip/CSharp/FillBehaviorTip.xaml#fillbehaviortipstoryboardcbutton)] @@ -90,16 +99,18 @@ When working with animations in WPF, there are a number of tips and tricks that That's because of the order in which WPF raises events and because property values are cached and are not recalculated unless the property is invalidated. The event is processed first because it was triggered by the root timeline (the first ). At this time, the property still returns its animated value because it hasn't been invalidated yet. The second uses the cached value as its starting value and begins animating. + ## Performance ### Animations Continue to Run After Navigating Away from a Page + When you navigate away from a that contains running animations, those animations will continue to play until the is garbage collected. Depending on the navigation system you're using, a page that you navigate away from might stay in memory for an indefinite amount of time, all the while consuming resources with its animations. This is most noticeable when a page contains constantly running ("ambient") animations. For this reason, it's a good idea to use the event to remove animations when you navigate away from a page. There are different ways to remove an animation. The following techniques can be used to remove animations that belong to a . -- To remove a you started with an event trigger, see [How to: Remove a Storyboard](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms749412(v=vs.90)). +- To remove a you started with an event trigger, see [How to: Remove a Storyboard](/previous-versions/dotnet/netframework-3.5/ms749412(v=vs.90)). - To use code to remove a , see the method. @@ -110,6 +121,7 @@ When working with animations in WPF, there are a number of tips and tricks that For more information about the different ways to animate properties, see [Property Animation Techniques Overview](property-animation-techniques-overview.md). ### Using the Compose HandoffBehavior Consumes System Resources + When you apply a , , or to a property using the , any objects previously associated with that property continue to consume system resources; the timing system will not remove these clocks automatically. To avoid performance issues when you apply a large number of clocks using , you should remove composing clocks from the animated property after they complete. There are several ways to remove a clock. diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/bitmap-effects-overview.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/bitmap-effects-overview.md index 26ea36f071..20af6d7882 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/bitmap-effects-overview.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/bitmap-effects-overview.md @@ -6,13 +6,16 @@ helpviewer_keywords: ms.assetid: 23cb338e-4b59-4b52-b294-96431f9c9568 --- # Bitmap Effects Overview + Bitmap effects enable designers and developers to apply visual effects to rendered Windows Presentation Foundation (WPF) content. For example, bitmap effects allow you to easily apply a effect or a blur effect to an image or a button. > [!IMPORTANT] > In the .NET Framework 4 or later, the class is obsolete. If you try to use the class, you will get an obsolete exception. The non-obsolete alternative to the class is the class. In most situations, the class is significantly faster. + ## WPF Bitmap Effects + Bitmap effects ( object) are simple pixel processing operations. A bitmap effect takes a as an input and produces a new after applying the effect, such as a blur or drop shadow. Each bitmap effect exposes properties that can control the filtering properties, such as of . As a special case, in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)], effects can be set as properties on live objects, such as a or . The pixel processing is applied and rendered at run-time. In this case, at the time of rendering, a is automatically converted to its equivalent and is fed as input to the . The output replaces the object's default rendering behavior. This is why objects force visuals to render in software only i.e. no hardware acceleration on visuals when effects are applied. @@ -29,12 +32,13 @@ Bitmap effects enable designers and developers to apply visual effects to render > [!NOTE] > WPF bitmap effects are rendered in software mode. Any object that applies an effect will also be rendered in software. Performance is degraded the most when using Bitmap effects on large visuals or animating properties of a Bitmap effect. This is not to say that you should not use Bitmap effects in this way at all, but you should use caution and test thoroughly to ensure that your users are getting the experience you expect. - > [!NOTE] > WPF bitmap effects do not support partial trust execution. An application must have full trust permissions to use bitmap effects. + ## How to Apply an Effect + is a property on . Therefore applying effects to Visuals, such as a , , , or , is as easy as setting a property. can be set to a single object or multiple effects can be chained by using the object. The following example demonstrates how to apply a in [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)]. @@ -49,15 +53,17 @@ Bitmap effects enable designers and developers to apply visual effects to render > When a is applied to a layout container, such as or , the effect is applied to the visual tree of the element or visual, including all of its child elements. + ## Creating Custom Effects - WPF also provides unmanaged interfaces to create custom effects that can be used in managed WPF applications. For additional reference material for creating custom bitmap effects, see the [Unmanaged WPF Bitmap Effect](https://docs.microsoft.com/previous-versions/windows/desktop/wibe/-wibe-lh) documentation. + + WPF also provides unmanaged interfaces to create custom effects that can be used in managed WPF applications. For additional reference material for creating custom bitmap effects, see the [Unmanaged WPF Bitmap Effect](/previous-versions/windows/desktop/wibe/-wibe-lh) documentation. ## See also - - - -- [Unmanaged WPF Bitmap Effect](https://docs.microsoft.com/previous-versions/windows/desktop/wibe/-wibe-lh) +- [Unmanaged WPF Bitmap Effect](/previous-versions/windows/desktop/wibe/-wibe-lh) - [Imaging Overview](imaging-overview.md) - [Security](../security-wpf.md) - [WPF Graphics Rendering Overview](wpf-graphics-rendering-overview.md) diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/drawing-objects-overview.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/drawing-objects-overview.md index 1942fb350e..9ae75fda03 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/drawing-objects-overview.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/drawing-objects-overview.md @@ -12,10 +12,13 @@ helpviewer_keywords: ms.assetid: 9b5ce5c0-e204-4320-a7a8-0b2210d62f88 --- # Drawing Objects Overview + This topic introduces objects and describes how to use them to efficiently draw shapes, bitmaps, text, and media. Use objects when you create clip art, paint with a , or use objects. -## What Is a Drawing Object? + +## What Is a Drawing Object + A object describes visible content, such as a shape, bitmap, video, or a line of text. Different types of drawings describe different types of content. The following is a list of the different types of drawing objects. - – Draws a shape. @@ -43,7 +46,9 @@ This topic introduces objects and describes Because they are a type object, objects gain several special features, which include the following: they can be declared as [resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define), shared among multiple objects, made read-only to improve performance, cloned, and made thread-safe. For more information about the different features provided by objects, see the [Freezable Objects Overview](../advanced/freezable-objects-overview.md). + ## Draw a Shape + To draw a shape, you use a . A geometry drawing's property describes the shape to draw, its property describes how the interior of the shape should be painted, and its property describes how its outline should be drawn. The following example uses a to draw a shape. The shape is described by a and two objects. The shape's interior is painted with a and its outline is drawn with a . @@ -63,7 +68,9 @@ A GeometryDrawing For more information about other ways to draw shapes that don't use objects, see [Shapes and Basic Drawing in WPF Overview](shapes-and-basic-drawing-in-wpf-overview.md). + ## Draw an Image + To draw an image, you use an . An object's property describes the image to draw, and its property defines the region where the image is drawn. The following example draws an image into a rectangle located at (75,75) that is 100 by 100 pixel. The following illustration shows the created by the example. A gray border was added to show the bounds of the . @@ -77,6 +84,7 @@ A 100 by 100 ImageDrawing For more information about images, see the [Imaging Overview](imaging-overview.md). + ## Play Media (Code Only) > [!NOTE] @@ -142,7 +150,9 @@ A 100 by 100 ImageDrawing Note that, when you use a , you use the interactive returned from the property of the to control media playback instead of the interactive methods of . + ## Draw Text + To draw text, you use a and a . The following example uses a to draw the text "Hello World". [!code-csharp[DrawingMiscSnippets_snip#GlyphRunDrawingExampleInline](~/samples/snippets/csharp/VS_Snippets_Wpf/DrawingMiscSnippets_snip/CSharp/GlyphRunDrawingExample.cs#glyphrundrawingexampleinline)] @@ -151,7 +161,9 @@ A 100 by 100 ImageDrawing A is a low-level object intended for use with fixed-format document presentation and print scenarios. A simpler way to draw text to the screen is to use a or a . For more information about , see the [Introduction to the GlyphRun Object and Glyphs Element](../advanced/introduction-to-the-glyphrun-object-and-glyphs-element.md) overview. + ## Composite Drawings + A enables you to combine multiple drawings into a single composite drawing. By using a , you can combine shapes, images, and text into a single object. The following example uses a to combine two objects and an object. This example produces the following output. @@ -173,15 +185,17 @@ Order of DrawingGroup operations |Property|Description|Illustration| |--------------|-----------------|------------------| -||Alters the opacity of selected portions of the contents. For an example, see [How to: Control the Opacity of a Drawing](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms748242(v=vs.90)).|![A DrawingGroup with an opacity mask](./media/graphicsmm-opmask.png "graphicsmm_opmask")| -||Uniformly changes the opacity of the contents. Use this property to make a transparent or partially transparent. For an example, see [How to: Apply an Opacity Mask to a Drawing](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms753195(v=vs.90)).|![DrawingGroups with different opacity settings](./media/graphicsmm-opacity.png "graphicsmm_opacity")| -||Applies a to the contents. For an example, see [How to: Apply a BitmapEffect to a Drawing](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms752341(v=vs.90)).|![DrawingGroup with a BlurBitmapEffect](./media/graphicsmm-bitmap.png "graphicsmm_bitmap")| -||Clips the contents to a region you describe using a . For an example, see [How to: Clip a Drawing](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms743068(v=vs.90)) .|![DrawingGroup with a defined clip region](./media/graphicsmm-clipgeom.png "graphicsmm_clipgeom")| +||Alters the opacity of selected portions of the contents. For an example, see [How to: Control the Opacity of a Drawing](/previous-versions/dotnet/netframework-3.5/ms748242(v=vs.90)).|![A DrawingGroup with an opacity mask](./media/graphicsmm-opmask.png "graphicsmm_opmask")| +||Uniformly changes the opacity of the contents. Use this property to make a transparent or partially transparent. For an example, see [How to: Apply an Opacity Mask to a Drawing](/previous-versions/dotnet/netframework-3.5/ms753195(v=vs.90)).|![DrawingGroups with different opacity settings](./media/graphicsmm-opacity.png "graphicsmm_opacity")| +||Applies a to the contents. For an example, see [How to: Apply a BitmapEffect to a Drawing](/previous-versions/dotnet/netframework-3.5/ms752341(v=vs.90)).|![DrawingGroup with a BlurBitmapEffect](./media/graphicsmm-bitmap.png "graphicsmm_bitmap")| +||Clips the contents to a region you describe using a . For an example, see [How to: Clip a Drawing](/previous-versions/dotnet/netframework-3.5/ms743068(v=vs.90)) .|![DrawingGroup with a defined clip region](./media/graphicsmm-clipgeom.png "graphicsmm_clipgeom")| ||Snaps device independent pixels to device pixels along the specified guidelines. This property is useful for ensuring that finely detailed graphics render sharply on low-DPI displays. For an example, see [Apply a GuidelineSet to a Drawing](how-to-apply-a-guidelineset-to-a-drawing.md).|![A DrawingGroup with and without a GuidelineSet](./media/graphicsmm-drawinggroup-guidelineset.png "graphicsmm_drawinggroup_guidelineset")| -||Transforms the contents. For an example, see [How to: Apply a Transform to a Drawing](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms742304(v=vs.90)).|![A rotated DrawingGroup](./media/graphicsmm-rotate.png "graphicsmm_rotate")| +||Transforms the contents. For an example, see [How to: Apply a Transform to a Drawing](/previous-versions/dotnet/netframework-3.5/ms742304(v=vs.90)).|![A rotated DrawingGroup](./media/graphicsmm-rotate.png "graphicsmm_rotate")| + ## Display a Drawing as an Image + To display a with an control, use a as the control's and set the object's property to the drawing you want to display. The following example uses a and an control to display a . This example produces the following output. @@ -193,7 +207,9 @@ A DrawingImage [!code-xaml[DrawingMiscSnippets_snip#DrawingImageExampleWholePage](~/samples/snippets/xaml/VS_Snippets_Wpf/DrawingMiscSnippets_snip/XAML/DrawingImageExample.xaml#drawingimageexamplewholepage)] + ## Paint an Object with a Drawing + A is a type of brush that paints an area with a drawing object. You can use it to paint just about any graphical object with a drawing. The property of a describes its . To render a with a , add it to the brush using the brush's property and use the brush to paint a graphical object, such as a control or panel. The following examples uses a to paint the of a with a pattern created from a . This example produces the following output. @@ -207,11 +223,15 @@ A GeometryDrawing used with a DrawingBrush The class provides a variety of options for stretching and tiling its content. For more information about , see the [Painting with Images, Drawings, and Visuals](painting-with-images-drawings-and-visuals.md) overview. + ## Render a Drawing with a Visual + A is a type of visual object designed to render a drawing. Working directly at the visual layer is an option for developers who want to build a highly customized graphical environment, and is not described in this overview. For more information, see the [Using DrawingVisual Objects](using-drawingvisual-objects.md) overview. + ## DrawingContext Objects + The class enables you to populate a or a with visual content. Many such lower-level graphics objects use a because it describes graphical content very efficiently. Although the draw methods appear similar to the draw methods of the type, they are actually very different. is used with a retained mode graphics system, while the type is used with an immediate mode graphics system. When you use a object's draw commands, you are actually storing a set of rendering instructions (although the exact storage mechanism depends on the type of object that supplies the ) that will later be used by the graphics system; you are not drawing to the screen in real-time. For more information about how the Windows Presentation Foundation (WPF) graphics system works, see the [WPF Graphics Rendering Overview](wpf-graphics-rendering-overview.md). @@ -219,7 +239,9 @@ A GeometryDrawing used with a DrawingBrush You never directly instantiate a ; you can, however, acquire a drawing context from certain methods, such as and . + ## Enumerate the Contents of a Visual + In addition to their other uses, objects also provide an object model for enumerating the contents of a . The following example uses the method to retrieve the value of a and enumerate it. diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-render-on-a-per-frame-interval-using-compositiontarget.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-render-on-a-per-frame-interval-using-compositiontarget.md index 6293b52469..680672b9cd 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-render-on-a-per-frame-interval-using-compositiontarget.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-render-on-a-per-frame-interval-using-compositiontarget.md @@ -10,14 +10,16 @@ helpviewer_keywords: ms.assetid: 701246cd-66b7-4d69-ada9-17b3b433d95d --- # How to: Render on a Per Frame Interval Using CompositionTarget + The [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] animation engine provides many features for creating frame-based animation. However, there are application scenarios in which you need finer-grained control over rendering on a per frame basis. The object provides the ability to create custom animations based on a per-frame callback. is a static class which represents the display surface on which your application is being drawn. The event is raised each time the application's scene is drawn. The rendering frame rate is the number of times the scene is drawn per second. > [!NOTE] -> For a complete code sample using , see [Using the CompositionTarget Sample](https://go.microsoft.com/fwlink/?LinkID=160045). +> For a complete code sample using , see [Using the CompositionTarget Sample](https://github.com/microsoft/WPF-Samples/tree/master/Visual%20Layer/CompositionTarget). ## Example + The event fires during the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] rendering process. The following example shows how you register an delegate to the static method on . [!code-csharp[CompositionTargetSample#CompositionTarget1](~/samples/snippets/csharp/VS_Snippets_Wpf/CompositionTargetSample/CSharp/Window1.xaml.cs#compositiontarget1)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/imaging-overview.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/imaging-overview.md index 963adceaa3..d5bf71c8bf 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/imaging-overview.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/imaging-overview.md @@ -23,9 +23,11 @@ helpviewer_keywords: ms.assetid: 72aad87a-e6f3-4937-94cd-a18b7766e990 --- # Imaging Overview + This topic provides an introduction to the Microsoft Windows Presentation Foundation Imaging Component. WPF Imaging enables developers to display, transform, and format images. ## WPF Imaging Component + WPF Imaging provides significant enhancements in imaging capabilities within Microsoft Windows. Imaging capabilities, such as displaying a bitmap or using an image on a common control were previously reliant upon the Microsoft Windows Graphics Device Interface (GDI) or Microsoft Windows GDI+ libraries. These API provide baseline imaging functionality, but lack features such as support for codec extensibility and high fidelity image support. WPF Imaging is designed to overcome the shortcomings of GDI and GDI+ and provide a new set of API to display and use images within your applications. There are two ways to access the WPF Imaging API, a managed component and an unmanaged component. The unmanaged component provides the following features. @@ -49,6 +51,7 @@ This topic provides an introduction to the Microsoft Windows Presentation Founda This topic provides additional information about the managed component. For more information on the unmanaged API see the [Unmanaged WPF Imaging Component](/windows/desktop/wic/-wic-lh) documentation. + ## WPF Image Formats A codec is used to decode or encode a specific media format. WPF Imaging includes a codec for BMP, JPEG, PNG, TIFF, Windows Media Photo, GIF, and ICON image formats. Each of these codecs enable applications to decode and, with the exception of ICON, encode their respective image formats. @@ -63,6 +66,7 @@ This topic provides an introduction to the Microsoft Windows Presentation Founda [!code-vb[BitmapFrameExample#10](~/samples/snippets/visualbasic/VS_Snippets_Wpf/BitmapFrameExample/VB/BitmapFrame.vb#10)] ### Image Format Decoding + Image decoding is the translation of an image format to image data that can be used by the system. The image data can then be used to display, process, or encode to a different format. Decoder selection is based on the image format. Codec selection is automatic unless a specific decoder is specified. The examples in the [Displaying Images in WPF](#_displayingimages) section demonstrate automatic decoding. Custom format decoders developed using the unmanaged WPF Imaging interfaces and registered with the system automatically participate in decoder selection. This allows custom formats to be displayed automatically in WPF applications. The following example demonstrates the use of a bitmap decoder to decode a BMP format image. @@ -72,6 +76,7 @@ This topic provides an introduction to the Microsoft Windows Presentation Founda [!code-vb[BmpBitmapDecoderEncoder#5](~/samples/snippets/visualbasic/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/VB/BitmapFrame.vb#5)] ### Image Format Encoding + Image encoding is the translation of image data to a specific image format. The encoded image data can then be used to create new image files. WPF Imaging provides encoders for each of the image formats described above. The following example demonstrates the use of an encoder to save a newly created bitmap image. @@ -81,10 +86,13 @@ This topic provides an introduction to the Microsoft Windows Presentation Founda [!code-vb[BmpBitmapDecoderEncoder#3](~/samples/snippets/visualbasic/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/VB/BitmapFrame.vb#3)] + ## Displaying Images in WPF + There are several ways to display an image in a Windows Presentation Foundation (WPF) application. Images can be displayed using an control, painted on a visual using an , or drawn using an . ### Using the Image Control + is a framework element and the primary way to display images in applications. In [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)], can be used in two ways; attribute syntax or property syntax. The following example shows how to render an image 200 pixels wide using both attribute syntax and property tag syntax. For more information on attribute syntax and property syntax, see [Dependency Properties Overview](../advanced/dependency-properties-overview.md). [!code-xaml[ImageElementExample_snip#ImageSimpleExampleInlineMarkup](~/samples/snippets/csharp/VS_Snippets_Wpf/ImageElementExample_snip/CSharp/ImageSimpleExample.xaml#imagesimpleexampleinlinemarkup)] @@ -100,6 +108,7 @@ This topic provides an introduction to the Microsoft Windows Presentation Founda [!code-vb[ImageElementExample_snip#ImageSimpleExampleInlineCode1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ImageElementExample_snip/VB/ImageSimpleExample.xaml.vb#imagesimpleexampleinlinecode1)] #### Rotating, Converting, and Cropping Images + WPF enables users to transform images by using properties of or by using additional objects such as or . These image transformations can scale or rotate an image, change the pixel format of an image, or crop an image. Image rotations are performed using the property of . Rotations can only be done in 90 degree increments. In the following example, an image is rotated 90 degrees. @@ -124,6 +133,7 @@ This topic provides an introduction to the Microsoft Windows Presentation Founda [!code-vb[ImageElementExample_snip#CroppedCSharpUsingClip1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ImageElementExample_snip/VB/CroppedImageExample.xaml.vb#croppedcsharpusingclip1)] #### Stretching Images + The property controls how an image is stretched to fill its container. The property accepts the following values, defined by the enumeration: - : The image is not stretched to fill the output area. If the image is larger than the output area, the image is drawn to the output area, clipping what does not fit. @@ -144,6 +154,7 @@ Different stretch settings [!code-xaml[ImageElementExample_snip#ImageStretchExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/ImageElementExample_snip/CSharp/ImageStretchExample.xaml#imagestretchexamplewholepage)] ### Painting with Images + Images can also be displayed in an application by painting with a . Brushes enable you to paint [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] objects with anything from simple, solid colors to complex sets of patterns and images. To paint with images, use an . An is a type of that defines its content as a bitmap image. An displays a single image, which is specified by its property. You can control how the image is stretched, aligned, and tiled, enabling you to prevent distortion and produce patterns and other effects. The following illustration shows some effects that can be achieved with an . ![ImageBrush output examples](./media/wcpsdk-mmgraphics-imagebrushexamples.gif "wcpsdk_mmgraphics_imagebrushexamples") @@ -156,7 +167,9 @@ Image brushes can fill shapes, controls, text, and more For additional information about and painting images see [Painting with Images, Drawings, and Visuals](painting-with-images-drawings-and-visuals.md). + ## Image Metadata + Some image files contain metadata that describes the content or the characteristics of the file. For example, most digital cameras create images that contain metadata about the make and model of the camera used to capture the image. Each image format handles metadata differently but WPF Imaging provides a uniform way of storing and retrieving metadata for each supported image format. Access to metadata is provided through the property of a object. returns a object that includes all the metadata contained by the image. This data may be in one metadata schema or a combination of different schemes. WPF Imaging supports the following image metadata schemas: Exchangeable image file (Exif), tEXt (PNG Textual Data), image file directory (IFD), International Press Telecommunications Council (IPTC), and Extensible Metadata Platform (XMP). @@ -174,10 +187,12 @@ Image brushes can fill shapes, controls, text, and more [!code-vb[BitmapMetadata#SetQuery](~/samples/snippets/visualbasic/VS_Snippets_Wpf/BitMapMetadata/VB/BitmapMetadata.vb#setquery)] + ## Codec Extensibility + A core feature of WPF Imaging is the extensibility model for new image codecs. These unmanaged interfaces enable codec developers to integrate codecs with WPF so new image formats can automatically be used by WPF applications. - For a sample of the extensibility API, see the [Win32 Sample Codec](https://go.microsoft.com/fwlink/?LinkID=160052). This sample demonstrates how to create a decoder and encoder for a custom image format. + For a sample of the extensibility API, see the [Win32 Sample Codec](https://github.com/microsoft/WPF-Samples/tree/master/Graphics/AITCodec). This sample demonstrates how to create a decoder and encoder for a custom image format. > [!NOTE] > The codec must be digitally signed for the system to recognize it. @@ -189,4 +204,4 @@ Image brushes can fill shapes, controls, text, and more - - - [2D Graphics and Imaging](../advanced/optimizing-performance-2d-graphics-and-imaging.md) -- [Win32 Sample Codec](https://go.microsoft.com/fwlink/?LinkID=160052) +- [Win32 Sample Codec](https://github.com/microsoft/WPF-Samples/tree/master/Graphics/AITCodec) diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/index.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/index.md index 42cc586e00..ca97318dda 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/index.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/index.md @@ -118,7 +118,7 @@ WPF provides a set of 3D rendering capabilities that integrate with 2D graphics ![Screenshot of a sample showing 3D shapes with different textures.](./media/index/visual-three-dimensional-shape.png) -For more information, see [3D Graphics Overview](3-d-graphics-overview.md). For an introductory sample, see [3D Solids Sample](https://go.microsoft.com/fwlink/?LinkID=159964). +For more information, see [3D Graphics Overview](3-d-graphics-overview.md). For an introductory sample, see [3D Solids Sample](https://github.com/microsoft/WPF-Samples/tree/master/Animation/AnimationExamples). diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/property-animation-techniques-overview.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/property-animation-techniques-overview.md index 087866d131..614c06ff3e 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/property-animation-techniques-overview.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/property-animation-techniques-overview.md @@ -11,14 +11,19 @@ helpviewer_keywords: ms.assetid: 74f61413-f8c0-4e75-bf04-951886426c8b --- # Property Animation Techniques Overview + This topic describes the different approaches for animating properties: storyboards, local animations, clocks, and per-frame animations. + ## Prerequisites + To understand this topic, you should be familiar with the basic animation features described in the [Animation Overview](animation-overview.md). + ## Different Ways to Animate + Because there are many different scenarios for animating properties, [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] provides several approaches for animating properties. For each approach, the following table indicates whether it can be used per-instance, in styles, in control templates, or in data templates; whether it can be used in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)]; and whether the approach enables you to interactively control the animation. "Per-Instance" refers to the technique of applying an animation or storyboard directly to instances of an object, rather than in a style, control template, or data template. @@ -31,7 +36,9 @@ This topic describes the different approaches for animating properties: storyboa |Per-frame animation|Per-instance|No|N/A| + ## Storyboard Animations + Use a when you want to define and apply your animations in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)], interactively control your animations after they start, create a complex tree of animations, or animate in a , or . For an object to be animated by a , it must be a or , or it must be used to set a or . For more details, see the [Storyboards Overview](storyboards-overview.md). A is a special type of container that provides targeting information for the animations it contains. To animate with a , you complete the following three steps. @@ -52,12 +59,13 @@ This topic describes the different approaches for animating properties: storyboa |--------------------------------|-------------------|-----------|----------------------|-------------------|-------------| | and an |Yes|Yes|Yes|Yes|[Animate a Property by Using a Storyboard](how-to-animate-a-property-by-using-a-storyboard.md)| | and a property |No|Yes|Yes|Yes|[Trigger an Animation When a Property Value Changes](how-to-trigger-an-animation-when-a-property-value-changes.md)| -| and a |No|Yes|Yes|Yes|[How to: Trigger an Animation When Data Changes](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/aa970679(v=vs.90))| +| and a |No|Yes|Yes|Yes|[How to: Trigger an Animation When Data Changes](/previous-versions/dotnet/netframework-3.5/aa970679(v=vs.90))| | method|Yes|No|No|No|[Animate a Property by Using a Storyboard](how-to-animate-a-property-by-using-a-storyboard.md)| For more information about objects, see the [Storyboards Overview](storyboards-overview.md). ## Local Animations + Local animations provide a convenient way to animate a dependency property of any object. Use local animations when you want to apply a single animation to a property and you don't need to interactively control the animation after it starts. Unlike a animation, a local animation can animate an object that isn't associated with a or a . You also don't have to define a for this type of animation. Local animations may only be used in code, and cannot be defined in styles, control templates, or data templates. A local animation cannot be interactively controlled after it is started. @@ -75,6 +83,7 @@ This topic describes the different approaches for animating properties: storyboa [!code-vb[animateproperty#11](~/samples/snippets/visualbasic/VS_Snippets_Wpf/animateproperty/VisualBasic/LocalAnimationExample.vb#11)] ## Clock Animations + Use objects when you want to animate without using a and you want to create complex timing trees or interactively control animations after they start. You can use Clock objects to animate a dependency property of any object. You cannot use objects directly to animate in styles, control templates, or data templates. (The animation and timing system actually does use objects to animate in styles, control templates, and data templates, but it must create those objects for you from a . For more information about the relationship between objects and objects, see the [Animation and Timing System Overview](animation-and-timing-system-overview.md).) @@ -103,6 +112,7 @@ This topic describes the different approaches for animating properties: storyboa For more information about Clock objects, see the [Animation and Timing System Overview](animation-and-timing-system-overview.md). ## Per-Frame Animation: Bypass the Animation and Timing System + Use this approach when you need to completely bypass the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] animation system. One scenario for this approach is physics animations, where each step in the animation requires objects to be recomputed based on the last set of object interactions. Per-frame animations cannot be defined inside styles, control templates, or data templates. diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/storyboards-overview.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/storyboards-overview.md index ea7b6b675d..c92da92c5b 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/storyboards-overview.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/storyboards-overview.md @@ -21,7 +21,7 @@ To understand this topic, you should be familiar with the different animation ty -## What Is a Storyboard? +## What Is a Storyboard Animations are not the only useful type of timeline. Other timeline classes are provided to help you organize sets of timelines, and to apply timelines to properties. Container timelines derive from the class, and include and . @@ -37,7 +37,7 @@ In this case, you have multiple sets of animations that apply to the same object -## Where Can You Use a Storyboard? +## Where Can You Use a Storyboard A can be used to animate dependency properties of animatable classes (for more information about what makes a class animatable, see the [Animation Overview](animation-overview.md)). However, because storyboarding is a framework-level feature, the object must belong to the of a or a . @@ -65,7 +65,7 @@ The following table shows the different places where each and an |Yes|Yes|Yes|Yes|[Animate a Property by Using a Storyboard](how-to-animate-a-property-by-using-a-storyboard.md)| | and a property |No|Yes|Yes|Yes|[Trigger an Animation When a Property Value Changes](how-to-trigger-an-animation-when-a-property-value-changes.md)| -| and a |No|Yes|Yes|Yes|[How to: Trigger an Animation When Data Changes](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/aa970679(v=vs.90))| +| and a |No|Yes|Yes|Yes|[How to: Trigger an Animation When Data Changes](/previous-versions/dotnet/netframework-3.5/aa970679(v=vs.90))| | method|Yes|No|No|No|[Animate a Property by Using a Storyboard](how-to-animate-a-property-by-using-a-storyboard.md)| The following example uses a to animate the of a element and the of a used to paint that . diff --git a/dotnet-desktop-guide/framework/wpf/security-wpf.md b/dotnet-desktop-guide/framework/wpf/security-wpf.md index 40da297975..bd0cdc09e3 100644 --- a/dotnet-desktop-guide/framework/wpf/security-wpf.md +++ b/dotnet-desktop-guide/framework/wpf/security-wpf.md @@ -15,6 +15,7 @@ helpviewer_keywords: ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb --- # Security (WPF) + When developing Windows Presentation Foundation (WPF) standalone and browser-hosted applications, you must consider the security model. WPF standalone applications execute with unrestricted permissions ( CAS**FullTrust** permission set), whether deployed using Windows Installer (.msi), XCopy, or ClickOnce. Deploying partial-trust, standalone WPF applications with ClickOnce is unsupported. However, a full-trust host application can create a partial-trust using the .NET Framework Add-in model. For more information, see [WPF Add-Ins Overview](./app-development/wpf-add-ins-overview.md). WPF browser-hosted applications are hosted by Windows Internet Explorer or Firefox, and can be either XAML browser applications (XBAPs) or loose [!INCLUDE[TLA#tla_xaml](../../includes/tlasharptla-xaml-md.md)] documents For more information, see [WPF XAML Browser Applications Overview](./app-development/wpf-xaml-browser-applications-overview.md). @@ -38,7 +39,9 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb - [Resources for Developing WPF Applications that Promote Security](#BestPractices) + ## Safe Navigation + For XBAPs, WPF distinguishes two types of navigation: application and browser. *Application navigation* is navigation between items of content within an application that is hosted by a browser. *Browser navigation* is navigation that changes the content and location URL of a browser itself. The relationship between application navigation (typically XAML) and browser navigation (typically HTML) is shown in the following illustration: @@ -48,7 +51,9 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb The type of content that is considered safe for an XBAP to navigate to is primarily determined by whether application navigation or browser navigation is used. + ### Application Navigation Security + Application navigation is considered safe if it can be identified with a pack URI, which supports four types of content: |Content Type|Description|URI Example| @@ -68,7 +73,9 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb - **Programmatic Navigation**. The application navigates without involving the user, for example, by setting the property. + ### Browser Navigation Security + Browser navigation is considered safe only under the following conditions: - **User Navigation**. The user navigates by clicking a element that is within the main , not in a nested . @@ -80,8 +87,10 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb If an XBAP attempts to navigate to content in a manner that does not comply with these conditions, a is thrown. + ## Web Browsing Software Security Settings - The security settings on your computer determine the access that any Web browsing software is granted. Web browsing software includes any application or component that uses the [WinINet](/windows/win32/wininet/portal) or [UrlMon](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767916(v=vs.85)) APIs, including Internet Explorer and PresentationHost.exe. + + The security settings on your computer determine the access that any Web browsing software is granted. Web browsing software includes any application or component that uses the [WinINet](/windows/win32/wininet/portal) or [UrlMon](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767916(v=vs.85)) APIs, including Internet Explorer and PresentationHost.exe. Internet Explorer provides a mechanism by which you can configure the functionality that is allowed to be executed by or from Internet Explorer, including the following: @@ -123,7 +132,9 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb By default, these settings are all enabled for the **Internet**, **Local intranet**, and **Trusted sites** zones, and disabled for the **Restricted sites** zone. + ### Security-related WPF Registry Settings + In addition to the security settings available through the Internet Options, the following registry values are available for selectively blocking a number of security-sensitive WPF features. The values are defined under the following key: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Windows Presentation Foundation\Features` @@ -141,15 +152,17 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb |ScriptInteropDisallow|REG_DWORD|1 to disallow; 0 to allow.| + ## WebBrowser Control and Feature Controls - The WPF control can be used to host Web content. The WPF control wraps the underlying WebBrowser ActiveX control. WPF provides some support for securing your application when you use the WPF control to host untrusted Web content. However, some security features must be applied directly by the applications using the control. For more information about the WebBrowser ActiveX control, see [WebBrowser Control Overviews and Tutorials](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752041(v=vs.85)). + + The WPF control can be used to host Web content. The WPF control wraps the underlying WebBrowser ActiveX control. WPF provides some support for securing your application when you use the WPF control to host untrusted Web content. However, some security features must be applied directly by the applications using the control. For more information about the WebBrowser ActiveX control, see [WebBrowser Control Overviews and Tutorials](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752041(v=vs.85)). > [!NOTE] > This section also applies to the control since it uses the to navigate to HTML content. If the WPF control is used to host untrusted Web content, your application should use a partial-trust to help insulate your application code from potentially malicious HTML script code. This is especially true if your application is interacting with the hosted script by using the method and the property. For more information, see [WPF Add-Ins Overview](./app-development/wpf-add-ins-overview.md). - If your application uses the WPF control, another way to increase security and mitigate attacks is to enable Internet Explorer feature controls. Feature controls are additions to Internet Explorer that allow administrators and developers to configure features of Internet Explorer and applications that host the WebBrowser ActiveX control, which the WPF control wraps. Feature controls can be configured by using the [CoInternetSetFeatureEnabled](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537168(v=vs.85)) function or by changing values in the registry. For more information about feature controls, see [Introduction to Feature Controls](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537184(v=vs.85)) and [Internet Feature Controls](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/general-info/ee330720(v=vs.85)). + If your application uses the WPF control, another way to increase security and mitigate attacks is to enable Internet Explorer feature controls. Feature controls are additions to Internet Explorer that allow administrators and developers to configure features of Internet Explorer and applications that host the WebBrowser ActiveX control, which the WPF control wraps. Feature controls can be configured by using the [CoInternetSetFeatureEnabled](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537168(v=vs.85)) function or by changing values in the registry. For more information about feature controls, see [Introduction to Feature Controls](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537184(v=vs.85)) and [Internet Feature Controls](/previous-versions/windows/internet-explorer/ie-developer/general-info/ee330720(v=vs.85)). If you are developing a standalone WPF application that uses the WPF control, WPF automatically enables the following feature controls for your application. @@ -203,13 +216,15 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb If you run a partial-trust XAML browser application (XBAP) that includes a WPF control in Windows Internet Explorer, WPF hosts the WebBrowser ActiveX control in the address space of the Internet Explorer process. Since the WebBrowser ActiveX control is hosted in the Internet Explorer process, all of the feature controls for Internet Explorer are also enabled for the WebBrowser ActiveX control. - XBAPs running in Internet Explorer also get an additional level of security compared to normal standalone applications. This additional security is because Internet Explorer, and therefore the WebBrowser ActiveX control, runs in protected mode by default on Windows Vista and Windows 7. For more information about protected mode, see [Understanding and Working in Protected Mode Internet Explorer](https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/). + XBAPs running in Internet Explorer also get an additional level of security compared to normal standalone applications. This additional security is because Internet Explorer, and therefore the WebBrowser ActiveX control, runs in protected mode by default on Windows Vista and Windows 7. For more information about protected mode, see [Understanding and Working in Protected Mode Internet Explorer](/previous-versions/windows/internet-explorer/ie-developer/). > [!NOTE] > If you try to run an XBAP that includes a WPF control in Firefox, while in the Internet zone, a will be thrown. This is due to WPF security policy. + ## Disabling APTCA Assemblies for Partially Trusted Client Applications + When managed assemblies are installed into the global assembly cache (GAC), they become fully trusted because the user must provide explicit permission to install them. Because they are fully trusted, only fully trusted managed client applications can use them. To allow partially trusted applications to use them, they must be marked with the (APTCA). Only assemblies that have been tested to be safe for execution in partial trust should be marked with this attribute. However, it is possible for an APTCA assembly to exhibit a security flaw after being installed into the GAC . Once a security flaw is discovered, assembly publishers can produce a security update to fix the problem on existing installations, and to protect against installations that may occur after the problem is discovered. One option for the update is to uninstall the assembly, although that may break other fully trusted client applications that use the assembly. @@ -238,7 +253,9 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb > Core .NET Framework assemblies are not affected by disabling them in this way because they are required for managed applications to run. Support for disabling APTCA assemblies is primarily targeted to third-party applications. + ## Sandbox Behavior for Loose XAML Files + Loose [!INCLUDE[TLA2#tla_xaml](../../includes/tla2sharptla-xaml-md.md)] files are markup-only XAML files that do not depend on any code-behind, event handler, or application-specific assembly. When loose [!INCLUDE[TLA2#tla_xaml](../../includes/tla2sharptla-xaml-md.md)] files are navigated to directly from the browser, they are loaded in a security sandbox based on the default Internet zone permission set. However, the security behavior is different when loose [!INCLUDE[TLA2#tla_xaml](../../includes/tla2sharptla-xaml-md.md)] files are navigated to from either a or in a standalone application. @@ -255,12 +272,14 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb > Even though navigation to loose [!INCLUDE[TLA2#tla_xaml](../../includes/tla2sharptla-xaml-md.md)] files from either a or in a standalone application is implemented based on the WPF browser hosting infrastructure, involving the PresentationHost process, the security level is slightly less than when the content is loaded directly in Internet Explorer on Windows Vista and Windows 7 (which would still be through PresentationHost). This is because a standalone WPF application using a Web browser does not provide the additional Protected Mode security feature of Internet Explorer. + ## Resources for Developing WPF Applications that Promote Security + The following are some additional resources to help develop WPF applications that promote security: |Area|Resource| |----------|--------------| -|Managed code|[Patterns and Practices Security Guidance for Applications](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10))| +|Managed code|[Patterns and Practices Security Guidance for Applications](/previous-versions/msp-n-p/ff650760(v=pandp.10))| |CAS|[Code Access Security](/dotnet/framework/misc/code-access-security)| |ClickOnce|[ClickOnce Security and Deployment](/visualstudio/deployment/clickonce-security-and-deployment)| |WPF|[WPF Partial Trust Security](wpf-partial-trust-security.md)| @@ -270,7 +289,7 @@ ms.assetid: ee1baea0-3611-4e36-9ad6-fcd5205376fb - [WPF Partial Trust Security](wpf-partial-trust-security.md) - [WPF Security Strategy - Platform Security](wpf-security-strategy-platform-security.md) - [WPF Security Strategy - Security Engineering](wpf-security-strategy-security-engineering.md) -- [Patterns and Practices Security Guidance for Applications](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)) +- [Patterns and Practices Security Guidance for Applications](/previous-versions/msp-n-p/ff650760(v=pandp.10)) - [Code Access Security](/dotnet/framework/misc/code-access-security) - [ClickOnce Security and Deployment](/visualstudio/deployment/clickonce-security-and-deployment) - [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml) diff --git a/dotnet-desktop-guide/framework/wpf/wpf-security-strategy-platform-security.md b/dotnet-desktop-guide/framework/wpf/wpf-security-strategy-platform-security.md index 7b8c22f798..43e60f4e40 100644 --- a/dotnet-desktop-guide/framework/wpf/wpf-security-strategy-platform-security.md +++ b/dotnet-desktop-guide/framework/wpf/wpf-security-strategy-platform-security.md @@ -19,6 +19,7 @@ helpviewer_keywords: ms.assetid: 2a39a054-3e2a-4659-bcb7-8bcea490ba31 --- # WPF Security Strategy - Platform Security + While Windows Presentation Foundation (WPF) provides a variety of security services, it also leverages the security features of the underlying platform, which includes the operating system, the CLR, and Internet Explorer. These layers combine to provide WPF a strong, defense-in-depth security model that attempts to avoid any single point of failure, as shown in the following figure: ![Diagram that shows the WPF security model.](./media/wpf-security-strategy-platform-security/windows-presentation-foundation-security.png) @@ -26,9 +27,11 @@ While Windows Presentation Foundation (WPF) provides a variety of security servi The remainder of this topic discusses the features in each of these layers that pertain to WPF specifically. ## Operating System Security + The core of Windows provides several security features that form the security foundation for all Windows applications, including those built with WPF. This topic discusses the breadth of these security features that are important to WPF, as well as how WPF integrates with them to provide further defense-in-depth. ### Microsoft Windows XP Service Pack 2 (SP2) + In addition to a general review and strengthening of Windows, there are three key features from Windows XP SP2 that we will discuss in this topic: - /GS compilation @@ -36,6 +39,7 @@ The core of Windows provides several security features that form the security fo - Microsoft Windows Update. #### /GS Compilation + Windows XP SP2 provides protection by recompiling many core system libraries, including all of the WPF dependencies such as the CLR, to help mitigate buffer overruns. This is achieved by using the /GS parameter with the C/C++ command-line compiler. Although buffer overruns should be explicitly avoided, /GS compilation provides an example of a defense-in-depth against potential vulnerabilities that are inadvertently or maliciously created by them. Historically, buffer overruns have been the cause of many high-impact security exploits. A buffer overrun occurs when an attacker takes advantage of a code vulnerability that allows the injection of malicious code that writes past the boundaries of a buffer. This then allows an attacker to hijack the process in which the code is executing by overwriting the return address of a function to cause the execution of the attacker's code. The result is malicious code that executes arbitrary code with the same privileges as the hijacked process. @@ -45,9 +49,11 @@ The core of Windows provides several security features that form the security fo WPF is compiled with the /GS flag to add yet another layer of defense to WPF applications. ### Windows Vista + WPF users on Windows Vista will benefit from the operating system's additional security enhancements, including "Least-Privilege User Access", code integrity checks, and privilege isolation. #### User Account Control (UAC) + Today, Windows users tend to run with administrator privileges because many applications require them for either installation or execution, or both. Being able to write default application settings to the Registry is one example. Running with administrator privileges really means that applications execute from processes that are granted administrator privileges. The security impact of this is that any malicious code that hijacks a process running with administrator privileges will automatically inherit those privileges, including access to critical system resources. @@ -59,19 +65,23 @@ WPF users on Windows Vista will benefit from the operating system's additional s - To provide compatibility solutions like virtualization. For example, many applications try to write to restricted locations like C:\Program Files. For applications executing under UAC, an alternative per-user location exists that does not require administrator privileges to write to. For applications running under UAC, UAC virtualizes C:\Program Files so that applications who think they are writing to it are actually writing to the alternative, per-user location. This kind of compatibility work enables the operating system to run many applications that couldn't previously run in UAC. #### Code Integrity Checks + Windows Vista incorporates deeper code integrity checks to help prevent malicious code from being injected into system files or into the kernel at load/run time. This goes beyond system file protection. ### Limited Rights Process for Browser-Hosted Applications + Browser-hosted WPF applications execute within the Internet zone sandbox. WPF integration with Microsoft Internet Explorer extends this protection with additional support. Since XAML browser applications (XBAPs) are generally sandboxed by the Internet zone permission set, removing these privileges does not harm XAML browser applications (XBAPs) from a compatibility perspective. Instead, an additional defense-in-depth layer is created; if a sandboxed application is able to exploit other layers and hijack the process, the process will still only have limited privileges. - See [Using a Least-Privileged User Account](https://docs.microsoft.com/previous-versions/tn-archive/cc700846%28v=technet.10%29). + See [Using a Least-Privileged User Account](/previous-versions/tn-archive/cc700846%28v=technet.10%29). ## Common Language Runtime Security + The common language runtime (CLR) offers a number of key security benefits that include validation and verification, Code Access Security (CAS), and the Security Critical Methodology. ### Validation and Verification + To provide assembly isolation and integrity, the CLR uses a process of validation. CLR validation ensures that assemblies are isolated by validating their Portable Executable (PE) file format for addresses that point outside the assembly. CLR validation also validates the integrity of the metadata that is embedded within an assembly. To ensure type safety, help prevent common security issues (e.g. buffer overruns), and enable sandboxing through sub-process isolation, CLR security uses the concept of verification. @@ -89,6 +99,7 @@ WPF users on Windows Vista will benefit from the operating system's additional s The advantage of verifiable code is a key reason why WPF builds on the .NET Framework. To the extent that verifiable code is used, the possibility of exploiting possible vulnerabilities is greatly lowered. ### Code Access Security + A client machine exposes a wide variety of resources that a managed application can have access to, including the file system, the Registry, printing services, the user interface, reflection, and environment variables. Before a managed application can access any of the resources on a client machine, it must have .NET Framework permission to do so. A permission in CAS is a subclass of the ; CAS implements one subclass for each resource that managed applications can access. The set of permissions that a managed application is granted by CAS when it starts executing is known as a permission set and is determined by evidence provided by the application. For WPF applications, the evidence that is provided is the location, or zone, from which the applications are launched. CAS identifies the following zones: @@ -148,11 +159,13 @@ WPF users on Windows Vista will benefit from the operating system's additional s From a platform perspective, WPF is responsible for using **Assert** correctly; an incorrect use of **Assert** could enable malicious code to elevate privileges. Consequently, it is important then to only call **Assert** when needed, and to ensure that sandbox restrictions remain intact. For example, sandboxed code is not allowed to open random files, but it is allowed to use fonts. WPF enables sandboxed applications to use font functionality by calling **Assert**, and for WPF to read files known to contain those fonts on behalf of the sandboxed application. ### ClickOnce Deployment + ClickOnce is a comprehensive deployment technology that is included with .NET Framework, and integrates with Visual Studio (see [ClickOnce security and deployment](/visualstudio/deployment/clickonce-security-and-deployment) for detailed information). Standalone WPF applications can be deployed using ClickOnce, while browser-hosted applications must be deployed with ClickOnce. Applications deployed using ClickOnce are given an additional security layer over Code Access Security (CAS); essentially, ClickOnce deployed applications request the permissions that they need. They are granted only those permissions if they do not exceed the set of permissions for the zone from which the application is deployed. By reducing the set of permissions to only those that are needed, even if they are less than those provided by the launch zone's permission set, the number of resources that the application has access to is reduced to a bare minimum. Consequently, if the application is hijacked, the potential for damage to the client machine is reduced. ### Security-Critical Methodology + The WPF code that uses permissions to enable the Internet zone sandbox for XBAP applications must be held to highest possible degree of security audit and control. To facilitate this requirement, .NET Framework provides new support for managing code that elevates privilege. Specifically, the CLR enables you to identify code that elevates privilege and mark it with the ; any code not marked with becomes *transparent* using this methodology. Conversely, managed code that is not marked with is prevented from elevating privilege. The Security-Critical Methodology allows the organization of WPF code that elevates privilege into *security-critical kernel*, with the remainder being transparent. Isolating the security-critical code enables the WPF engineering team focus an additional security analysis and source control on the security-critical kernel above and beyond standard security practices (see [WPF Security Strategy - Security Engineering](wpf-security-strategy-security-engineering.md)). @@ -160,6 +173,7 @@ WPF users on Windows Vista will benefit from the operating system's additional s Note that .NET Framework permits trusted code to extend the XBAP Internet zone sandbox by allowing developers to write managed assemblies that are marked with (APTCA) and deployed to the user's Global Assembly Cache (GAC). Marking an assembly with APTCA is a highly sensitive security operation as it allows any code to call that assembly, including malicious code from the Internet. Extreme caution and best practices must be used when doing this and users must choose to trust that software in order for it to be installed. ## Microsoft Internet Explorer Security + Beyond reducing security issues and simplifying security configuration, Microsoft Internet Explorer 6 (SP2) contains several features that security improvements that enhance security for users of XAML browser applications (XBAPs). The thrust of these features attempts to allow users greater control over their browsing experience. Prior to IE6 SP2, users could be subject to any of the following: diff --git a/dotnet-desktop-guide/framework/wpf/wpf-security-strategy-security-engineering.md b/dotnet-desktop-guide/framework/wpf/wpf-security-strategy-security-engineering.md index d2b7a6440f..dfa43f4bda 100644 --- a/dotnet-desktop-guide/framework/wpf/wpf-security-strategy-security-engineering.md +++ b/dotnet-desktop-guide/framework/wpf/wpf-security-strategy-security-engineering.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: 0fc04394-4e47-49ca-b0cf-8cd1161d95b9 --- # WPF Security Strategy - Security Engineering + Trustworthy Computing is a Microsoft initiative for ensuring the production of secure code. A key element of the Trustworthy Computing initiative is the Microsoft Security Development Lifecycle (SDL). The SDL is an engineering practice that is used in conjunction with standard engineering processes to facilitate the delivery of secure code. The SDL consists of ten phases that combine best practices with formalization, measurability, and additional structure, including: - Security design analysis @@ -25,6 +26,7 @@ Trustworthy Computing is a Microsoft initiative for ensuring the production of s - Post release product security management ## WPF Specifics + The [!INCLUDE[TLA2#tla_winclient](../../includes/tla2sharptla-winclient-md.md)] engineering team both applies and extends the SDL, the combination of which includes the following key aspects: [Threat Modeling](#threat_modeling) @@ -36,7 +38,9 @@ Trustworthy Computing is a Microsoft initiative for ensuring the production of s [Critical Code Management](#critical_code) + ### Threat Modeling + Threat modeling is a core component of the SDL, and is used to profile a system to determine potential security vulnerabilities. Once the vulnerabilities are identified, threat modeling also ensures that appropriate mitigations are in place. At a high level, threat modeling involves the following key steps by using a grocery store as an example: @@ -58,17 +62,21 @@ Trustworthy Computing is a Microsoft initiative for ensuring the production of s These threat models are important for identifying security design requirements and threat mitigations during the development process. + ### Source Analysis and Editing Tools + In addition to the manual security code review elements of the SDL, the [!INCLUDE[TLA2#tla_winclient](../../includes/tla2sharptla-winclient-md.md)] team uses several tools for source analysis and associated edits to decrease security vulnerabilities. A wide range of source tools are used, and include the following: -- **FXCop**: Finds common security issues in managed code ranging from inheritance rules to code access security usage to how to safely interoperate with unmanaged code. See [FXCop](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.0/bb429476%28v=vs.80%29). +- **FXCop**: Finds common security issues in managed code ranging from inheritance rules to code access security usage to how to safely interoperate with unmanaged code. See [FXCop](/previous-versions/dotnet/netframework-3.0/bb429476%28v=vs.80%29). - **Prefix/Prefast**: Finds security vulnerabilities and common security issues in unmanaged code such as buffer overruns, format string issues, and error checking. - **Banned APIs**: Searches source code to identify accidental usage of functions that are well-known for causing security issues, such as `strcpy`. Once identified, these functions are replaced with alternatives that are more secure. + ### Testing Techniques + [!INCLUDE[TLA2#tla_winclient](../../includes/tla2sharptla-winclient-md.md)] uses a variety of security testing techniques that include: - **Whitebox Testing**: Testers view source code, and then build exploit tests. @@ -80,7 +88,9 @@ Trustworthy Computing is a Microsoft initiative for ensuring the production of s - **Tools-Based Penetration Testing through File Fuzzing**: File fuzzing is the exploitation of a file reader's input range through a variety of inputs. One example in [!INCLUDE[TLA2#tla_winclient](../../includes/tla2sharptla-winclient-md.md)] where this technique is used is to check for failure in image decoding code. + ### Critical Code Management + For XAML browser applications (XBAPs), [!INCLUDE[TLA2#tla_winclient](../../includes/tla2sharptla-winclient-md.md)] builds a security sandbox by using .NET Framework support for marking and tracking security-critical code that elevates privileges (see **Security-Critical Methodology** in [WPF Security Strategy - Platform Security](wpf-security-strategy-platform-security.md)). Given the high security quality requirements on security critical code, such code receives an additional level of source management control and security audit. Approximately 5% to 10% of [!INCLUDE[TLA2#tla_winclient](../../includes/tla2sharptla-winclient-md.md)] consists of security-critical code, which is reviewed by a dedicated reviewing team. The source code and check-in process is managed by tracking security critical code and mapping each critical entity (i.e. a method that contains critical code) to its sign off state. The sign off state includes the names of one or more reviewers. Each daily build of [!INCLUDE[TLA2#tla_winclient](../../includes/tla2sharptla-winclient-md.md)] compares the critical code to that in previous builds to check for unapproved changes. If an engineer modifies critical code without approval from the reviewing team, it is identified and fixed immediately. This process enables the application and maintenance of an especially high level of scrutiny over [!INCLUDE[TLA2#tla_winclient](../../includes/tla2sharptla-winclient-md.md)] sandbox code. ## See also From 67f63a5a43b664d265096459254990c03a24cec0 Mon Sep 17 00:00:00 2001 From: David Coulter Date: Thu, 5 Nov 2020 14:05:06 -0800 Subject: [PATCH 4/5] Links: .NET Desktop - Pass 2 (#111) --- dotnet-desktop-guide/xaml-services/index.md | 2 +- .../xaml-services/type-converters-overview.md | 2 +- .../xaml-services/types-for-primitives.md | 26 +++++++++---------- .../xaml-services/xamlname-grammar.md | 2 +- .../xaml-services/xclass-directive.md | 8 +++--- .../xaml-services/xclassmodifier-directive.md | 3 ++- .../xaml-services/xkey-directive.md | 7 ++++- .../xaml-services/xmember-directive.md | 3 ++- .../xaml-services/xname-directive.md | 2 +- .../xaml-services/xproperty-directive.md | 2 +- .../xaml-services/xtypearguments-directive.md | 2 +- .../xaml-services/xuid-directive.md | 2 +- 12 files changed, 35 insertions(+), 26 deletions(-) diff --git a/dotnet-desktop-guide/xaml-services/index.md b/dotnet-desktop-guide/xaml-services/index.md index ff81dd998e..58905c6511 100644 --- a/dotnet-desktop-guide/xaml-services/index.md +++ b/dotnet-desktop-guide/xaml-services/index.md @@ -29,7 +29,7 @@ Conceptual documentation for .NET XAML Services assumes that you have previous e - Using the `Lookup` or `Invoker` techniques to influence the XAML type system and how type backings are evaluated. -If you are looking for introductory material on XAML as a language, you might try [XAML Overview (WPF)](../net/wpf/fundamentals/xaml.md). That topic discusses XAML for an audience that is new both to Windows Presentation Foundation (WPF) and also to using XAML markup and XAML language features. Another useful document is the introductory material in the [XAML language specification](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +If you are looking for introductory material on XAML as a language, you might try [XAML Overview (WPF)](../net/wpf/fundamentals/xaml.md). That topic discusses XAML for an audience that is new both to Windows Presentation Foundation (WPF) and also to using XAML markup and XAML language features. Another useful document is the introductory material in the [XAML language specification](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ## .NET XAML Services and `System.Xaml` in the .NET Architecture diff --git a/dotnet-desktop-guide/xaml-services/type-converters-overview.md b/dotnet-desktop-guide/xaml-services/type-converters-overview.md index 40539e94fb..672a07be44 100644 --- a/dotnet-desktop-guide/xaml-services/type-converters-overview.md +++ b/dotnet-desktop-guide/xaml-services/type-converters-overview.md @@ -60,7 +60,7 @@ The second-most important method is implementation can uniquely interpret what is a valid string for a conversion, and it can also use or ignore the type description that is passed as parameters. An important consideration for culture and XAML type conversion is the following: although using localizable strings as attribute values is supported by XAML, you cannot use these localizable strings as type converter input with specific culture requirements. This limitation is because type converters for XAML attribute values involve a necessarily fixed-language XAML-processing behavior that uses `en-US` culture. For more information about the design reasons for this restriction, see the XAML language specification ([\[MS-XAML\]](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10))) or [WPF Globalization and Localization Overview](../framework/wpf/advanced/wpf-globalization-and-localization-overview.md). +Each implementation can uniquely interpret what is a valid string for a conversion, and it can also use or ignore the type description that is passed as parameters. An important consideration for culture and XAML type conversion is the following: although using localizable strings as attribute values is supported by XAML, you cannot use these localizable strings as type converter input with specific culture requirements. This limitation is because type converters for XAML attribute values involve a necessarily fixed-language XAML-processing behavior that uses `en-US` culture. For more information about the design reasons for this restriction, see the XAML language specification ([\[MS-XAML\]](/previous-versions/msp-n-p/ff650760(v=pandp.10))) or [WPF Globalization and Localization Overview](../framework/wpf/advanced/wpf-globalization-and-localization-overview.md). As an example where culture can be an issue, some cultures use a comma instead of a period as the decimal point delimiter for numbers in string form. This use collides with the behavior that many existing type converters have, which is to use a comma as a delimiter. Passing a culture through `xml:lang` in the surrounding XAML does not solve the issue. diff --git a/dotnet-desktop-guide/xaml-services/types-for-primitives.md b/dotnet-desktop-guide/xaml-services/types-for-primitives.md index 6dc692024d..475e2e4c88 100644 --- a/dotnet-desktop-guide/xaml-services/types-for-primitives.md +++ b/dotnet-desktop-guide/xaml-services/types-for-primitives.md @@ -48,19 +48,19 @@ This primitive is not typically used in application markup, but might be useful For CLR backing, the `x:Boolean` primitive corresponds to . -XAML parses values for `x:Boolean` as case insensitive. Note that `x:Bool` is not an accepted alternative. For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.17 and 5.4.11](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +XAML parses values for `x:Boolean` as case insensitive. Note that `x:Bool` is not an accepted alternative. For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.17 and 5.4.11](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:Char For CLR backing, the `x:Char` primitive corresponds to . -String and char types have interaction with the overall encoding of the file at the XML level. For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.7 and 5.4.1](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +String and char types have interaction with the overall encoding of the file at the XML level. For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.7 and 5.4.1](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:String For CLR backing, the `x:String` primitive corresponds to . -String and char types have interaction with the overall encoding of the file at the XML level. For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.6](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +String and char types have interaction with the overall encoding of the file at the XML level. For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.6](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:Decimal @@ -68,7 +68,7 @@ For CLR backing, the `x:Decimal` primitive corresponds to . XAML parsing is inherently done under `en-US` culture. Under `en-US` culture, the correct separator for the components of a decimal is always a period (`.`) regardless of culture settings of the development environment, or of the eventual client target where the XAML is loaded at run time. -For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.14 and 5.4.8](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.14 and 5.4.8](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:Single @@ -78,7 +78,7 @@ In addition to the numeric values, text syntax for `x:Single` also permits the t `x:Single` can support values in scientific notation form, if the first character in text syntax is `e` or `E`. -For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.8 and 5.4.2](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.8 and 5.4.2](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:Double @@ -88,25 +88,25 @@ In addition to the numeric values, text syntax for `x:Double` permits the tokens `x:Double` can support values in scientific notation form. Use the character `e` or `E` to introduce the exponent portion. -For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.9 and 5.4.3](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.9 and 5.4.3](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:Int16 For CLR backing, the `x:Int16` primitive corresponds to and `x:Int16` is treated as signed. In XAML, the absence of a plus (`+`) sign in text syntax is implied as a positive signed value. -For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.11 and 5.4.5](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.11 and 5.4.5](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:Int32 For CLR backing, the `x:Int32` primitive corresponds to . `x:Int32` is treated as signed. In XAML, the absence of a plus (`+`) sign in text syntax is implied as a positive signed value. -For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.12 and 5.4.6](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.12 and 5.4.6](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:Int64 For CLR backing, the `x:Int64` primitive corresponds to . `x:Int64` is treated as signed. In XAML, the absence of a plus (`+`) sign in text syntax is implied as a positive signed value. -For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.13 and 5.4.7](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.13 and 5.4.7](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:TimeSpan @@ -114,7 +114,7 @@ For CLR backing, the `x:TimeSpan` primitive corresponds to . Checking for protocols is not part of the XAML definition for `x:Uri`. -For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.15 and 5.4.9](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.15 and 5.4.9](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:Byte For CLR backing, the `x:Byte` primitive corresponds to . A / `x:Byte` is treated as unsigned. -For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.10 and 5.4.4](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.10 and 5.4.4](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ### x:Array @@ -136,7 +136,7 @@ For CLR backing, the `x:Array` primitive corresponds to . You can define an array in XAML 2006 by using a markup extension syntax; however, the XAML 2009 syntax is a language-defined primitive that does not require accessing a markup extension. For more information about XAML 2006 support, see [x:Array Markup Extension](xarray-markup-extension.md). -For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.18](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the XAML language specification definition, see [\[MS-XAML\] Sections 5.2.18](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ## WPF Support diff --git a/dotnet-desktop-guide/xaml-services/xamlname-grammar.md b/dotnet-desktop-guide/xaml-services/xamlname-grammar.md index 611a4ebb5c..d8a6524384 100644 --- a/dotnet-desktop-guide/xaml-services/xamlname-grammar.md +++ b/dotnet-desktop-guide/xaml-services/xamlname-grammar.md @@ -52,4 +52,4 @@ DottedXamlName ::= XamlName '.' XamlName ## Remarks -For the complete specification, see [\[MS-XAML\]](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +For the complete specification, see [\[MS-XAML\]](/previous-versions/msp-n-p/ff650760(v=pandp.10)). diff --git a/dotnet-desktop-guide/xaml-services/xclass-directive.md b/dotnet-desktop-guide/xaml-services/xclass-directive.md index cb63088585..5ff855dc61 100644 --- a/dotnet-desktop-guide/xaml-services/xclass-directive.md +++ b/dotnet-desktop-guide/xaml-services/xclass-directive.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: bc4a3d8e-76e2-423e-a5d1-159a023e82ec --- # x:Class Directive + Configures XAML markup compilation to join partial classes between markup and code-behind. The code partial class is defined in a separate code file in a Common Language Specification (CLS) language, whereas the markup partial class is typically created by code generation during XAML compilation. ## XAML Attribute Usage @@ -31,7 +32,7 @@ Configures XAML markup compilation to join partial classes between markup and co ## Dependencies -`x:Class` can only be specified on the root element of a XAML production. `x:Class` is invalid on any object that has a parent in the XAML production. For more information, see [\[MS-XAML\] Section 4.3.1.6](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +`x:Class` can only be specified on the root element of a XAML production. `x:Class` is invalid on any object that has a parent in the XAML production. For more information, see [\[MS-XAML\] Section 4.3.1.6](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ## Remarks @@ -43,7 +44,7 @@ The value of the `x:Class` directive must be a string that specifies the fully q The code-behind file for a page or application definition must be within a code file that is included as part of the project that produces a compiled application and involves markup compilation. You must follow name rules for CLR classes. For more information, see [Framework Design Guidelines](/dotnet/api/). By default, the code-behind class must be `public`; however, you can define it at a different access level by using the [x:ClassModifier Directive](xclassmodifier-directive.md). -This interpretation of the `x:Class` attribute applies only to a CLR-based XAML implementation, in particular to .NET XAML Services. Other XAML implementations that are not based on CLR and that do not use .NET XAML Services might use a different resolution formula for connecting XAML markup and backing run-time code. For more information about more general interpretations of `x:Class`, see [\[MS-XAML\]](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +This interpretation of the `x:Class` attribute applies only to a CLR-based XAML implementation, in particular to .NET XAML Services. Other XAML implementations that are not based on CLR and that do not use .NET XAML Services might use a different resolution formula for connecting XAML markup and backing run-time code. For more information about more general interpretations of `x:Class`, see [\[MS-XAML\]](/previous-versions/msp-n-p/ff650760(v=pandp.10)). At a certain level of architecture, the meaning of `x:Class` is undefined in .NET XAML Services. This is because .NET XAML Services does not specify the programming model by which XAML markup and backing code are connected. Additional uses of the `x:Class` directive might be implemented by specific frameworks that use programming models or application models to define how to connect XAML markup and CLR-based code-behind. Each framework can have its own build actions that enable some of the behavior or specific components that must be included in the build environment. Within a framework, build actions can also vary depending on the specific CLR language that is used for the code-behind. @@ -52,11 +53,12 @@ At a certain level of architecture, the meaning of `x:Class` is undefined in .NE In WPF applications and the WPF application model, `x:Class` can be declared as an attribute for any element that is the root of a XAML file and is being compiled (where the XAML is included in a WPF application project with `Page` build action), or for the root in the application definition of a compiled WPF application. Declaring `x:Class` on an element other than a page root or application root, or on a WPF XAML file that is not compiled, causes a compile-time error under the .NET Framework 3.0 and .NET Framework 3.5 WPF XAML compiler. For information about other aspects of `x:Class` handling in WPF, see [Code-Behind and XAML in WPF](../framework/wpf/advanced/code-behind-and-xaml-in-wpf.md). ## x:Class for Windows Workflow Foundation + For Windows Workflow Foundation, `x:Class` names the class of a custom activity composed entirely in XAML, or names the partial class of the XAML page for an activity designer with code-behind. ## Silverlight Usage Notes -`x:Class` for Silverlight is documented separately. For more information, see [XAML Namespace (x:) Language Features (Silverlight)](https://docs.microsoft.com/previous-versions/windows/silverlight/dotnet-windows-silverlight/cc188995(v=vs.95)). +`x:Class` for Silverlight is documented separately. For more information, see [XAML Namespace (x:) Language Features (Silverlight)](/previous-versions/windows/silverlight/dotnet-windows-silverlight/cc188995(v=vs.95)). ## See also diff --git a/dotnet-desktop-guide/xaml-services/xclassmodifier-directive.md b/dotnet-desktop-guide/xaml-services/xclassmodifier-directive.md index c5b7ab4732..32f1318f15 100644 --- a/dotnet-desktop-guide/xaml-services/xclassmodifier-directive.md +++ b/dotnet-desktop-guide/xaml-services/xclassmodifier-directive.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: ef30ab78-d334-4668-917d-c9f66c3b6aea --- # x:ClassModifier Directive + Modifies XAML compilation behavior when `x:Class` is also provided. Specifically, instead of creating a partial `class` that has a `Public` access level (the default), the provided `x:Class` is created with a `NotPublic` access level. This behavior affects the access level for the class in the generated assemblies. ## XAML Attribute Usage @@ -30,7 +31,7 @@ Modifies XAML compilation behavior when `x:Class` is also provided. Specifically ## Dependencies -[x:Class](xclass-directive.md) must also be provided on the same element, and that element must be the root element in a page. For more information, see [\[MS-XAML\] Section 4.3.1.8](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +[x:Class](xclass-directive.md) must also be provided on the same element, and that element must be the root element in a page. For more information, see [\[MS-XAML\] Section 4.3.1.8](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ## Remarks diff --git a/dotnet-desktop-guide/xaml-services/xkey-directive.md b/dotnet-desktop-guide/xaml-services/xkey-directive.md index e257c31643..8c4d726e53 100644 --- a/dotnet-desktop-guide/xaml-services/xkey-directive.md +++ b/dotnet-desktop-guide/xaml-services/xkey-directive.md @@ -12,6 +12,7 @@ helpviewer_keywords: ms.assetid: 1985cd45-f197-42d5-b75e-886add64b248 --- # x:Key Directive + Uniquely identifies elements that are created and referenced in a XAML-defined dictionary. Adding an `x:Key` value to a XAML object element is the most common way to identify a resource in a resource dictionary, for example in a WPF . ## XAML Attribute Usage @@ -42,6 +43,7 @@ Uniquely identifies elements that are created and referenced in a XAML-defined d |`markupExtensionUsage`|Within the markup extension delimiters {}, a markup extension usage that provides an object to use as a key. See Remarks.| ## Remarks + `x:Key` supports the XAML resource dictionary concept. XAML as a language doesn't define a resource dictionary implementation, that is left to specific UI frameworks. To learn more about how XAML resource dictionaries are implemented in WPF, see [XAML Resources](../net/wpf/fundamentals/xaml-resources-define.md). In XAML 2006 and WPF, `x:Key` must be provided as an attribute. You can still use nonstring keys, but this requires a markup extension usage in order to provide the nonstring value in attribute form. If you are using XAML 2009, `x:Key` can be specified as an element, to explicitly support dictionaries keyed by object types other than strings without requiring a markup extension intermediate. See the "XAML 2009" section in this topic. The remainder of the Remarks section applies specifically to the XAML 2006 implementation. @@ -53,6 +55,7 @@ Uniquely identifies elements that are created and referenced in a XAML-defined d The code equivalent of specifying `x:Key` is the key that is used for the underlying . For example, an `x:Key` that is applied in markup for a resource in WPF is equivalent to the value of the `key` parameter of when you add the resource to a WPF in code. ## WPF Usage Notes + Child objects of a parent object that is an implementation, such as the WPF , must typically include an `x:Key` attribute, and the key value must be unique within that dictionary. There are two notable exceptions: - Some WPF types declare an implicit key for dictionary usage. For example, a with a , or a with a , can be in a and use the implicit key. @@ -72,6 +75,7 @@ Uniquely identifies elements that are created and referenced in a XAML-defined d The WPF merged dictionary feature introduces additional considerations for key uniqueness and key lookup behavior. For more information, see [Merged Resource Dictionaries](../framework/wpf/advanced/merged-resource-dictionaries.md). ## XAML 2009 + XAML 2009 relaxes the restriction that `x:Key` always be provided in attribute form. In WPF, you can use XAML 2009 features, but only for XAML that is not markup-compiled. Markup-compiled XAML for WPF and the BAML form of XAML do not currently support the XAML 2009 keywords and features. @@ -102,7 +106,8 @@ keyObject - `keyObject` could also be a markup extension usage in object element form, rather than a direct object instance. ## Silverlight Usage Notes - `x:Key` for Silverlight is documented separately. For more information, see [XAML Namespace (x:) Language Features (Silverlight)](https://docs.microsoft.com/previous-versions/windows/silverlight/dotnet-windows-silverlight/cc188995(v=vs.95)). + + `x:Key` for Silverlight is documented separately. For more information, see [XAML Namespace (x:) Language Features (Silverlight)](/previous-versions/windows/silverlight/dotnet-windows-silverlight/cc188995(v=vs.95)). ## See also diff --git a/dotnet-desktop-guide/xaml-services/xmember-directive.md b/dotnet-desktop-guide/xaml-services/xmember-directive.md index 6c395f6e4b..5aa78955f0 100644 --- a/dotnet-desktop-guide/xaml-services/xmember-directive.md +++ b/dotnet-desktop-guide/xaml-services/xmember-directive.md @@ -4,6 +4,7 @@ ms.date: "03/30/2017" ms.assetid: 4d8394ef-644c-4331-b6c5-be855d392980 --- # x:Member Directive + Declares a XAML member in markup. ## XAML Object Element Usage @@ -34,4 +35,4 @@ To support a practical usage of `x:Members` as a means to specify member definit ## x:Property for Windows Workflow Foundation -For Windows Workflow Foundation, `x:Property` defines the members of a custom activity composed entirely in XAML, or XAML –defined dynamic members for an activity designer with code-behind. `x:Class` must also be specified on the root element of the XAML production. This is not a requirement at .NET XAML Services level, but becomes a requirement when the XAML production is loaded by the MSBUILD build actions that support custom activities and Windows Workflow Foundation XAML in general. Windows Workflow Foundation does not use the pure XAML type name as its intended value for the `x:Property` `Type` attribute, and instead uses a convention that is not documented here. For more information, see [DynamicActivity Creation](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/dd807392(v=vs.100)). +For Windows Workflow Foundation, `x:Property` defines the members of a custom activity composed entirely in XAML, or XAML –defined dynamic members for an activity designer with code-behind. `x:Class` must also be specified on the root element of the XAML production. This is not a requirement at .NET XAML Services level, but becomes a requirement when the XAML production is loaded by the MSBUILD build actions that support custom activities and Windows Workflow Foundation XAML in general. Windows Workflow Foundation does not use the pure XAML type name as its intended value for the `x:Property` `Type` attribute, and instead uses a convention that is not documented here. For more information, see [DynamicActivity Creation](/previous-versions/dotnet/netframework-4.0/dd807392(v=vs.100)). diff --git a/dotnet-desktop-guide/xaml-services/xname-directive.md b/dotnet-desktop-guide/xaml-services/xname-directive.md index cc0c975ee9..7d52f4f071 100644 --- a/dotnet-desktop-guide/xaml-services/xname-directive.md +++ b/dotnet-desktop-guide/xaml-services/xname-directive.md @@ -63,7 +63,7 @@ If is available as a property on ## Silverlight Usage Notes -`x:Name` for Silverlight is documented separately. For more information, see [XAML Namespace (x:) Language Features (Silverlight)](https://docs.microsoft.com/previous-versions/windows/silverlight/dotnet-windows-silverlight/cc188995(v=vs.95)). +`x:Name` for Silverlight is documented separately. For more information, see [XAML Namespace (x:) Language Features (Silverlight)](/previous-versions/windows/silverlight/dotnet-windows-silverlight/cc188995(v=vs.95)). ## See also diff --git a/dotnet-desktop-guide/xaml-services/xproperty-directive.md b/dotnet-desktop-guide/xaml-services/xproperty-directive.md index ad1e90fae9..126b63f50c 100644 --- a/dotnet-desktop-guide/xaml-services/xproperty-directive.md +++ b/dotnet-desktop-guide/xaml-services/xproperty-directive.md @@ -36,4 +36,4 @@ To support a practical usage of `x:Members` as a means to specify member definit ## x:Property for Windows Workflow Foundation -For Windows Workflow Foundation, `x:Property` defines the members of a custom activity composed entirely in XAML, or XAML –defined dynamic members for an activity designer with code-behind. `x:Class` must also be specified on the root element of the XAML production. This is not a requirement at .NET XAML Services level, but becomes a requirement when the XAML production is loaded by the MSBUILD build actions that support custom activities and Windows Workflow Foundation XAML in general. Windows Workflow Foundation does not use the pure XAML type name as its intended value for the `x:Property` `Type` attribute, and instead uses a convention that is not documented here. For more information, see [DynamicActivity Creation](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/dd807392(v=vs.100)). +For Windows Workflow Foundation, `x:Property` defines the members of a custom activity composed entirely in XAML, or XAML –defined dynamic members for an activity designer with code-behind. `x:Class` must also be specified on the root element of the XAML production. This is not a requirement at .NET XAML Services level, but becomes a requirement when the XAML production is loaded by the MSBUILD build actions that support custom activities and Windows Workflow Foundation XAML in general. Windows Workflow Foundation does not use the pure XAML type name as its intended value for the `x:Property` `Type` attribute, and instead uses a convention that is not documented here. For more information, see [DynamicActivity Creation](/previous-versions/dotnet/netframework-4.0/dd807392(v=vs.100)). diff --git a/dotnet-desktop-guide/xaml-services/xtypearguments-directive.md b/dotnet-desktop-guide/xaml-services/xtypearguments-directive.md index cfc09f374a..876007dd69 100644 --- a/dotnet-desktop-guide/xaml-services/xtypearguments-directive.md +++ b/dotnet-desktop-guide/xaml-services/xtypearguments-directive.md @@ -36,7 +36,7 @@ You can specify more than one XAML type name by using a comma delimiter. If the generic constraints themselves use generic types, the nested constraint type arguments can be contained by parentheses (). -Note that this definition of `x:TypeArguments` is specific to .NET XAML Services and using CLR backing. A language-level definition can be found in [\[MS-XAML\] Section 5.3.11](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +Note that this definition of `x:TypeArguments` is specific to .NET XAML Services and using CLR backing. A language-level definition can be found in [\[MS-XAML\] Section 5.3.11](/previous-versions/msp-n-p/ff650760(v=pandp.10)). ## Usage Examples diff --git a/dotnet-desktop-guide/xaml-services/xuid-directive.md b/dotnet-desktop-guide/xaml-services/xuid-directive.md index d46b66afe7..c74d9916a7 100644 --- a/dotnet-desktop-guide/xaml-services/xuid-directive.md +++ b/dotnet-desktop-guide/xaml-services/xuid-directive.md @@ -26,7 +26,7 @@ Provides a unique identifier for markup elements. In many scenarios, this unique ## Remarks -In [MS-XAML], `x:Uid` is defined as a directive. For more information, see [\[MS-XAML\] Section 5.3.6](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)). +In [MS-XAML], `x:Uid` is defined as a directive. For more information, see [\[MS-XAML\] Section 5.3.6](/previous-versions/msp-n-p/ff650760(v=pandp.10)). `x:Uid` is discrete from `x:Name` both because of the stated XAML localization scenario and so that identifiers that are used for localization have no dependencies on the programming model implications of `x:Name`. Also, `x:Name` is governed by the XAML namescope; however, `x:Uid` is not governed by any XAML language defined concept of uniqueness enforcement. XAML processors in a broad sense (processors that are not part of the localization process) are not expected to enforce uniqueness of `x:Uid` values. That responsibility is conceptually on the originator of the values. The expectation of uniqueness of `x:Uid` values within a single XAML source is reasonable for consumers of the values, such as dedicated globalization processes or tools. The typical uniqueness model is that `x:Uid` values are unique within an XML-encoded file that represents XAML. From 8f3082cb43c51d4f4821c14fee938da213819f52 Mon Sep 17 00:00:00 2001 From: Andy De George <67293991+adegeo@users.noreply.github.com> Date: Thu, 5 Nov 2020 22:40:54 -0800 Subject: [PATCH 5/5] Inital migration article port (#110) * Inital migration article port * Acro * fix toc * Apply suggestions from code review Co-authored-by: Tom Dykstra * Updates * lint * Update dotnet-desktop-guide/net/winforms/get-started/create-app-visual-studio.md Co-authored-by: Tom Dykstra Co-authored-by: Tom Dykstra --- .../get-started/create-app-visual-studio.md | 3 +- .../net/winforms/migration/index.md | 227 ++++++++++++++++++ dotnet-desktop-guide/net/winforms/toc.yml | 4 + 3 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 dotnet-desktop-guide/net/winforms/migration/index.md diff --git a/dotnet-desktop-guide/net/winforms/get-started/create-app-visual-studio.md b/dotnet-desktop-guide/net/winforms/get-started/create-app-visual-studio.md index 54c67b312f..30ba752b3a 100644 --- a/dotnet-desktop-guide/net/winforms/get-started/create-app-visual-studio.md +++ b/dotnet-desktop-guide/net/winforms/get-started/create-app-visual-studio.md @@ -26,7 +26,8 @@ In this tutorial, you learn how to: ## Prerequisites - [Visual Studio 2019 version 16.8 Preview](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2019+desktopguide+winforms) -- [Visual Studio Desktop workload](/visualstudio/install/modify-visual-studio?view=vs-2019&preserve-view=true) + - Select the [Visual Studio Desktop workload](/visualstudio/install/modify-visual-studio?view=vs-2019&preserve-view=true#modify-workloads) + - Select the [.NET 5 individual component](/visualstudio/install/modify-visual-studio?view=vs-2019&preserve-view=true#modify-individual-components) ## Create a WinForms app diff --git a/dotnet-desktop-guide/net/winforms/migration/index.md b/dotnet-desktop-guide/net/winforms/migration/index.md new file mode 100644 index 0000000000..c588031b92 --- /dev/null +++ b/dotnet-desktop-guide/net/winforms/migration/index.md @@ -0,0 +1,227 @@ +--- +title: Migrate a Windows Forms app to .NET 5 +description: Learn how to port a .NET Framework Windows Forms application to .NET 5. +ms.date: 11/02/2020 +ms.topic: how-to +--- + +# How to migrate a Windows Forms desktop app to .NET 5 + +This article describes how to migrate a Windows Forms desktop app from .NET Framework to .NET 5 or later. The .NET SDK includes support for Windows Forms applications. Windows Forms is still a Windows-only framework and only runs on Windows. + +Migrating your app from .NET Framework to .NET 5 generally requires a new project file. .NET 5 uses SDK-style project files while .NET Framework typically uses the older Visual Studio project file. If you've ever opened a Visual Studio project file in a text editor, you know how verbose it is. SDK-style projects are smaller and don't require as many entries as the older project file format does. + +To learn more about .NET 5, see [Introduction to .NET](/dotnet/core/introduction). + +## Prerequisites + +- [Visual Studio 2019 version 16.8 Preview](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2019+desktopguide+winforms) + + - Select the [Visual Studio Desktop workload](/visualstudio/install/modify-visual-studio?view=vs-2019&preserve-view=true#modify-workloads). + + - Select the [.NET 5 individual component](/visualstudio/install/modify-visual-studio?view=vs-2019&preserve-view=true#modify-individual-components). + +- Preview WinForms designer in Visual Studio. + + To enable the designer, go to **Tools** > **Options** > **Environment** > **Preview Features** and select the **Use the preview Windows Forms designer for .NET Core apps** option. + +- This article uses the [Matching game](https://github.com/dotnet/samples/tree/master/windowsforms/matching-game/net45/) sample app. If you want to follow along, download and open the application in Visual Studio. Otherwise, use your own app. + +### Consider + +When migrating a .NET Framework Windows Forms application, there are a few things you must consider. + +01. Check that your application is a good candidate for migration. + + Use the [.NET Portability Analyzer](/dotnet/standard/analyzers/portability-analyzer) to determine if your project will migrate to .NET 5. If your project has issues with .NET 5, the analyzer helps you identify those problems. The .NET Portability Analyzer tool can be installed as a Visual Studio extension or used from the command line. For more information, see [.NET Portability Analyzer](/dotnet/standard/analyzers/portability-analyzer). + +01. You're using a different version of Windows Forms. + + When .NET Core 3.0 was released, Windows Forms went [open source on GitHub](https://github.com/dotnet/winforms). The code for Windows Forms for .NET 5 is a fork of the .NET Framework Windows Forms codebase. It's possible some differences exist and your app will be difficult to migrate. + +01. The [Windows Compatibility Pack][compat-pack] may help you migrate. + + Some APIs that are available in .NET Framework aren't available in .NET 5. The [Windows Compatibility Pack][compat-pack] adds many of these APIs and may help your Windows Forms app become compatible with .NET 5. + +01. Update the NuGet packages used by your project. + + It's always a good practice to use the latest versions of NuGet packages before any migration. If your application is referencing any NuGet packages, update them to the latest version. Ensure your application builds successfully. After upgrading, if there are any package errors, downgrade the package to the latest version that doesn't break your code. + +## Back up your projects + +The first step to migrating a project is to back up your project! If something goes wrong, you can restore your code to its original state by restoring your backup. Don't rely on tools such as the .NET Portability Analyzer to back up your project, even if they seem to. It's better to have a copy of the original project safely stored in the cloud or elsewhere on your computer. + +## NuGet packages + +If your project is referencing NuGet packages, you probably have a **packages.config** file in your project folder. With SDK-style projects, NuGet package references are configured in the project file. Visual Studio project files can optionally define NuGet packages in the project file too. .NET 5 doesn't use **packages.config** for NuGet packages. NuGet package references must be migrated into the project file before migration. + +To migrate the **packages.config** file, do the following: + +01. In **Solution explorer**, find the project you're migrating. +02. Right-click on **packages.config** > **Migrate packages.config to ProjectReference**. +03. Select all of the top-level packages. + +A build report is generated to let you know of any issues migrating the NuGet packages. + +## Project file + +The next step in migrating your app is converting the project file. As previously stated, .NET 5 uses SDK-style project files and won't load the Visual Studio project files that .NET Framework uses. However, there's the possibility that you're already using SDK-style projects. You can easily spot the difference in Visual Studio. Right-click on the project file in **Solution explorer** and look for the **Edit Project File** menu option. If this menu item is missing, you're using the old Visual Studio project format and need to upgrade. + +To upgrade, do the following: + +01. In **Solution explorer**, find the project you're migrating. +01. Right-click on the project and select **Unload Project**. +01. Right-click on the project and select **Edit Project File**. +01. Copy-and-paste the project XML into a text editor. You'll want a copy so that it's easy to move content into the new project. +01. Erase the content of the file and paste in the following content: + + ```xml + + + + WinExe + net5.0-windows + true + false + + + + ``` + + > [!IMPORTANT] + > Libraries don't need to define an `` setting. Remove that entry if you're upgrading a library project. + +This XML gives you the basic structure of the project. However, it doesn't contain any of the settings from the old project file. Using the old project information you previously copied to a text editor, do the following: + +01. Copy the following elements from the old project file into the `` element in the new project file: + + - `` + - `` + + Your project file should look similar to the following: + + ```xml + + + + WinExe + net5.0-windows + true + false + + MatchingGame + MatchingGame + + + + ``` + +01. Copy the `` elements from the old project file that contain `` or `` into the new file after the `` closing tag. + + Your project file should look similar to the following: + + ```xml + + + + (contains settings previously described) + + + + + {36b3e6e2-a9ae-4924-89ae-7f0120ce08bd} + MatchingGame.Logic + + + + + 1.2.0.3 + + + + + ``` + + The `` elements don't need the `` and `` children, so you can remove those: + + ```xml + + + + ``` + +### Resources and settings + +Windows Forms projects for .NET Framework typically include other files such as *Properties/Settings.settings* and *Properties/Resources.resx*. These files, and any *resx* file created for your app besides form *resx* files, would need to be migrated. + +Copy those entries from the old project file into an `` element in the new project. After you copy the entries, change any `` or `` elements to instead use `Update` instead of `Include`. + +- Import the configuration for the *Settings.settings* file. Note that `Include` was changed to `Update` on the `` element: + + ```xml + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + ``` + +- Import the configuration for any *resx* file, such as the *properties/Resources.resx* file. Note that `Include` was changed to `Update` on both the `` and `` elements, and `` was removed from ``: + + ```xml + + + ResXFileCodeGenerator + Resources.Designer.cs + + + True + Resources.resx + True + + + ``` + +Convert each project in your solution. If you're using the sample app previously referenced, the **MatchingGame.Logic** project would be converted. + +## Edit App.config + +If your app has an *App.config* file, remove the `` element. + +```xml + +``` + +There are some things you should consider with the *App.config* file. The *App.config* file in .NET Framework was used not only to configure the app, but to configure runtime settings and behavior, such as logging. The *App.config* file in .NET 5+ (and .NET Core) is no longer used for runtime configuration. If your *App.config* file has these sections, they won't be respected. + +## Add the compatibility package + +If compilation fails and you receive errors similar to the following: + +- **The type or namespace \ could not be found** +- **The name \ does not exist in the current context** + +You may need to add the [**Microsoft.Windows.Compatibility**](https://www.nuget.org/packages/Microsoft.Windows.Compatibility/) package to your app. This package adds ~21,000 .NET APIs from .NET Framework, such as the `System.Configuration.ConfigurationManager` class and APIs for interacting with the Windows Registry. + +```xml + + + +``` + +## Test your app + +After you've finished migrating your app, test it! + +## Next steps + +- Learn about [breaking changes from .NET Framework to .NET Core](/dotnet/core/compatibility/fx-core#windows-forms). +- Read more about the [Windows Compatibility Pack][compat-pack]. + +[compat-pack]: /dotnet/core/porting/windows-compat-pack diff --git a/dotnet-desktop-guide/net/winforms/toc.yml b/dotnet-desktop-guide/net/winforms/toc.yml index ea34719c6b..ed3f2a0ab3 100644 --- a/dotnet-desktop-guide/net/winforms/toc.yml +++ b/dotnet-desktop-guide/net/winforms/toc.yml @@ -7,6 +7,10 @@ items: href: overview/index.md - name: Create an app href: get-started/create-app-visual-studio.md +- name: Migration + items: + - name: Migrate to .NET 5 + href: migration/index.md - name: Forms items: - name: Event handlers