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