From d9125bf6eafd6bfe2fe6112974879f3fbdf866d5 Mon Sep 17 00:00:00 2001 From: Tris Shores <86677757+v-trisshores@users.noreply.github.com> Date: Fri, 4 Mar 2022 12:35:13 -0600 Subject: [PATCH 1/2] Content update - Handle events in Visual Basic (user story 1878475) (#1320) * Add article, toc, and redirects * Add code snippets * Fix a note in a prior event article * Add tip and fix lnk * Simplify snippet --- .openpublishing.redirection.json | 8 +++ .../how-to-add-an-event-handler-using-code.md | 2 +- .../vb/Application.xaml | 9 +++ .../vb/Application.xaml.vb | 6 ++ .../vb/AssemblyInfo.vb | 11 ++++ .../vb/CodeSampleVb.vbproj | 23 +++++++ .../vb/MainWindow.xaml | 15 +++++ .../vb/MainWindow.xaml.vb | 61 ++++++++++++++++++ .../visual-basic-and-wpf-event-handling.md | 64 +++++++++++++++++++ dotnet-desktop-guide/net/wpf/toc.yml | 2 + redirects_generator/definitions.json | 5 ++ 11 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/Application.xaml create mode 100644 dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/Application.xaml.vb create mode 100644 dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/AssemblyInfo.vb create mode 100644 dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/CodeSampleVb.vbproj create mode 100644 dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml create mode 100644 dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml.vb create mode 100644 dotnet-desktop-guide/net/wpf/events/visual-basic-and-wpf-event-handling.md diff --git a/.openpublishing.redirection.json b/.openpublishing.redirection.json index e1b7256..74ff216 100644 --- a/.openpublishing.redirection.json +++ b/.openpublishing.redirection.json @@ -620,6 +620,14 @@ { "source_path": "dotnet-desktop-guide/framework/wpf/events/how-to-create-a-custom-routed-event.md", "redirect_url": "/dotnet/desktop/wpf/advanced/how-to-create-a-custom-routed-event?view=netframeworkdesktop-4.8" + }, + { + "source_path": "dotnet-desktop-guide/net/wpf/advanced/visual-basic-and-wpf-event-handling.md", + "redirect_url": "/dotnet/desktop/wpf/events/visual-basic-and-wpf-event-handling?view=netdesktop-6.0" + }, + { + "source_path": "dotnet-desktop-guide/framework/wpf/events/visual-basic-and-wpf-event-handling.md", + "redirect_url": "/dotnet/desktop/wpf/advanced/visual-basic-and-wpf-event-handling?view=netframeworkdesktop-4.8" } ] } diff --git a/dotnet-desktop-guide/net/wpf/events/how-to-add-an-event-handler-using-code.md b/dotnet-desktop-guide/net/wpf/events/how-to-add-an-event-handler-using-code.md index 4bc9094..1940b86 100644 --- a/dotnet-desktop-guide/net/wpf/events/how-to-add-an-event-handler-using-code.md +++ b/dotnet-desktop-guide/net/wpf/events/how-to-add-an-event-handler-using-code.md @@ -66,7 +66,7 @@ The `ButtonCreatedByCode_Click` event handler obtains the following information - The object, which is the element that originally raised the event. In this example, the `Source` is always `ButtonCreatedByCode`. > [!NOTE] -> A key difference between a routed event and a CLR event is that a routed event traverses the element tree, whereas a CLR event occurs only on the `sender`. As a result, a routed event `sender` can be any traversed element in the element tree. +> A key difference between a routed event and a CLR event is that a routed event traverses the element tree, looking for handlers, whereas a CLR event doesn't traverse the element tree and handlers can only attach to the source object that raised the event. As a result, a routed event `sender` can be any traversed element in the element tree. For more information on how to create and handle routed events, see [How to create a custom routed event](/dotnet/desktop/wpf/advanced/how-to-create-a-custom-routed-event?view=netframeworkdesktop-4.8&preserve-view=true) and [Handle a routed event](/dotnet/desktop/wpf/advanced/how-to-handle-a-routed-event?view=netframeworkdesktop-4.8&preserve-view=true). diff --git a/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/Application.xaml b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/Application.xaml new file mode 100644 index 0000000..f225972 --- /dev/null +++ b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/Application.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/Application.xaml.vb b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/Application.xaml.vb new file mode 100644 index 0000000..084cbe9 --- /dev/null +++ b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/Application.xaml.vb @@ -0,0 +1,6 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + +End Class diff --git a/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/AssemblyInfo.vb b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/AssemblyInfo.vb new file mode 100644 index 0000000..025ee72 --- /dev/null +++ b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/AssemblyInfo.vb @@ -0,0 +1,11 @@ +Imports System.Windows + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + diff --git a/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/CodeSampleVb.vbproj b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/CodeSampleVb.vbproj new file mode 100644 index 0000000..90d032b --- /dev/null +++ b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/CodeSampleVb.vbproj @@ -0,0 +1,23 @@ + + + + WinExe + net6.0-windows + CodeSampleVb + en-us + true + + + + + + + + + + + + + + + diff --git a/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml new file mode 100644 index 0000000..859ea3c --- /dev/null +++ b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml.vb b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml.vb new file mode 100644 index 0000000..c34cf57 --- /dev/null +++ b/dotnet-desktop-guide/net/wpf/events/snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml.vb @@ -0,0 +1,61 @@ +Imports System.Windows.Controls.Primitives + +Namespace CodeSampleVb + + ' + ' Interaction logic for MainWindow.xaml. + ' + Partial Public Class MainWindow + Inherits Window + + Public Sub New() + + InitializeComponent() + + ' Add the new button to the StackPanel. + StackPanel1.Children.Add(CodeButton) + + ' Remove a handler. + ' RemoveHandler XamlButton.Click, AddressOf XamlButton_Click + + End Sub + + ' + ' Loaded event handler attached to the XAML page root using Handles. + Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + + ' Handler logic. + Debug.WriteLine($"Loaded event handler attached to Window using Handles.") + + End Sub + ' + + ' + ' Declare a new button using WithEvents. + Dim WithEvents CodeButton As New Button With { + .Content = "New button", + .Background = Brushes.Yellow + } + + ' Click event handler attached to CodeButton using Handles. + Private Sub CodeButton_Click(sender As Object, e As RoutedEventArgs) Handles CodeButton.Click + + ' Handler logic. + Debug.WriteLine($"Click event handler attached to CodeButton using Handles.") + + End Sub + ' + + ' + ' Click event handler attached to XamlButton using Handles. + Private Sub XamlButton_Click(sender As Object, e As RoutedEventArgs) Handles XamlButton.Click + + ' Handler logic. + Debug.WriteLine($"Click event handler attached to XamlButton using Handles.") + + End Sub + ' + + End Class + +End Namespace diff --git a/dotnet-desktop-guide/net/wpf/events/visual-basic-and-wpf-event-handling.md b/dotnet-desktop-guide/net/wpf/events/visual-basic-and-wpf-event-handling.md new file mode 100644 index 0000000..9236091 --- /dev/null +++ b/dotnet-desktop-guide/net/wpf/events/visual-basic-and-wpf-event-handling.md @@ -0,0 +1,64 @@ +--- +title: Visual Basic and WPF event handling +description: Learn how to attach handlers to Windows Presentation Foundation (WPF) routed events in Visual Basic. +ms.date: "02/25/2022" +helpviewer_keywords: + - "Visual Basic [WPF], event handlers" + - "event handlers [WPF], Visual Basic" +--- + + +# Visual Basic and WPF event handling (WPF .NET) + +If you're coding in Visual Basic .NET, you can use the language-specific [Handles](/dotnet/visual-basic/language-reference/statements/handles-clause) keyword to attach an event handler to an object. The object can be an instance in code-behind or an element in Extensible Application Markup Language (XAML). `Handles` can be used to assign event handlers for common language runtime (CLR) events or Windows Presentation Foundation (WPF) [routed events](/dotnet/desktop/wpf/advanced/routed-events-overview?view=netframeworkdesktop-4.8&preserve-view=true). However, `Handles` has some usage [limitations](#limitations) when used to attach event handlers for routed events. + +[!INCLUDE [desktop guide under construction](../../includes/desktop-guide-preview-note.md)] + +## Syntax + +The syntax for a `Sub` declaration that uses the [Handles](/dotnet/visual-basic/language-reference/statements/handles-clause) keyword is: `Sub Handles .`. That syntax designates a procedure as the event handler that will run when an event specified by `` is raised on an object specified by ``. The event must be a member of the object's class or base class. The following example shows how to attach an event handler to a XAML element using `Handles`. + +:::code language="vb" source="./snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml.vb" id="XamlButton_Click"::: + +To use `Handles` with an object defined in code-behind, typically you declare the object using the [WithEvents](/dotnet/visual-basic/language-reference/modifiers/withevents) keyword. For more information on `WithEvents` usage, see these [examples](/dotnet/visual-basic/language-reference/statements/handles-clause#example-1). WPF automatically declares all XAML elements using `Friend WithEvents`. The following example shows how to declare an object defined in code-behind using `WithEvents`. + +:::code language="vb" source="./snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml.vb" id="CodeButton_Click"::: + +To use the same handler for multiple events, comma-separate the `.` events. For example, `Sub Button_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click, Button2.Click`. The order of the comma-separated events is immaterial. + +You can assign different handlers for the same event with multiple `Handles` statements. The order of the `Handles` statements doesn't determine the order in which handlers are invoked when the event occurs. + +> [!TIP] +> To remove a handler that was added with `Handles`, call [RemoveHandler](/dotnet/visual-basic/language-reference/statements/removehandler-statement). For example, `RemoveHandler Button1.Click, AddressOf Button1_Click`. + +## Using 'Handles' in a WPF application + +For an object defined in XAML, the [Handles](/dotnet/visual-basic/language-reference/statements/handles-clause) event syntax `.` requires the XAML element that represents the object to have a or [x:Name](/dotnet/desktop/xaml-services/xname-directive) property. However, a name property isn't required for the XAML page root element, for which you can use the name `Me`. The following example shows how to attach an event handler to an XAML page root using `Handles`. + +:::code language="vb" source="./snippets/visual-basic-and-wpf-event-handling/vb/MainWindow.xaml.vb" id="Window_Loaded"::: + +When a XAML page is compiled, every XAML element with a `Name` or `x:Name` parameter is declared as `Friend WithEvents`. As a result, you can use any XAML element with `Handles`. + +> [!TIP] +> Visual Studio IntelliSense shows the objects that can be used with `Handles`. + +Regardless whether you attach an event handler using `Handles`, XAML attribute syntax, the [AddHandler](/dotnet/visual-basic/language-reference/statements/addhandler-statement) statement, or the method, the event system behavior is the same. + +> [!NOTE] +> Don't use both XAML attributes and `Handles` to attach the same event handler to the same event, otherwise the event handler will get called twice for each event. + +## Limitations + +The [Handles](/dotnet/visual-basic/language-reference/statements/handles-clause) keyword has these usage limitations: + +- You can only use `Handles` to attach an event handler to an object if the event is a member of the object's class or base class. For example, you can use `Handles` to attach a event handler to a button whose base class raises the `Click` routed event. However, one of the features of [routed events](/dotnet/desktop/wpf/advanced/routed-events-overview?view=netframeworkdesktop-4.8&preserve-view=true) is that they traverse the element tree, which makes it possible to listen for and handle a `Click` event at a higher level than the element that raised it. A routed event that a parent element listens for and handles is called an _attached event_. `Handles` can't be used for attached events because its syntax doesn't support specifying a different listener in the XAML element tree than the element that raised the event. To assign event handlers for attached events, you'll need to use either XAML attribute syntax or the method. For more information on attached events, see [Attached events overview](/dotnet/desktop/wpf/advanced/attached-events-overview?view=netframeworkdesktop-4.8&preserve-view=true) and [Attached events in WPF](/dotnet/desktop/wpf/advanced/routed-events-overview?view=netframeworkdesktop-4.8&preserve-view=true#attached-events-in-wpf). + +- `Handles` syntax doesn't support event handler invocation for events. To enable your event handler to be invoked for `Handled` events, attach the event handler using the method and set its `handledEventsToo` parameter to `true`. + +## See also + +- +- [Marking routed events as handled, and class handling](/dotnet/desktop/wpf/advanced/marking-routed-events-as-handled-and-class-handling?view=netframeworkdesktop-4.8&preserve-view=true) +- [Routed events overview](/dotnet/desktop/wpf/advanced/routed-events-overview?view=netframeworkdesktop-4.8&preserve-view=true) +- [Attached events overview](/dotnet/desktop/wpf/advanced/attached-events-overview?view=netframeworkdesktop-4.8&preserve-view=true) +- [XAML in WPF](/dotnet/desktop/wpf/advanced/xaml/index?view=netframeworkdesktop-4.8&preserve-view=true) diff --git a/dotnet-desktop-guide/net/wpf/toc.yml b/dotnet-desktop-guide/net/wpf/toc.yml index 26bb8d7..40579a1 100644 --- a/dotnet-desktop-guide/net/wpf/toc.yml +++ b/dotnet-desktop-guide/net/wpf/toc.yml @@ -80,6 +80,8 @@ items: items: - name: Events items: + - name: Visual Basic and WPF event handling + href: events/visual-basic-and-wpf-event-handling.md - name: Common tasks items: - name: Add an event handler using code diff --git a/redirects_generator/definitions.json b/redirects_generator/definitions.json index ef2d8b7..d143353 100644 --- a/redirects_generator/definitions.json +++ b/redirects_generator/definitions.json @@ -338,6 +338,11 @@ "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-create-a-custom-routed-event?view=netframeworkdesktop-4.8", "TargetUrl": "/dotnet/desktop/wpf/events/how-to-create-a-custom-routed-event?view=netdesktop-6.0" }, + { + "Redirect": "TwoWay", + "SourceUrl": "/dotnet/desktop/wpf/advanced/visual-basic-and-wpf-event-handling?view=netframeworkdesktop-4.8", + "TargetUrl": "/dotnet/desktop/wpf/events/visual-basic-and-wpf-event-handling?view=netdesktop-6.0" + }, // Systems - Properties { From 6d665a13bdfb3739d716d480697bb79c97497708 Mon Sep 17 00:00:00 2001 From: Pooja Poojari <95325584+poojapoojari@users.noreply.github.com> Date: Sat, 5 Mar 2022 00:18:05 +0530 Subject: [PATCH 2/2] US-1889327: Updated H2 headings. (#1323) * Updated H2 headings for US-1889327. * Review edits. * Apply suggestions from code review Co-authored-by: Andy (Steve) De George <67293991+adegeo@users.noreply.github.com> --- .../how-to-use-a-custom-context-menu-with-a-textbox.md | 6 ++++-- .../how-to-use-spell-checking-with-a-context-menu.md | 6 ++++-- .../wpf/controls/how-to-use-the-image-element.md | 6 ++++-- ...position-the-cursor-at-the-beginning-or-end-of-text.md | 7 ++++--- .../wpf/controls/statusbar-styles-and-templates.md | 4 +++- .../framework/wpf/getting-started/index.md | 5 +++-- .../extend-glass-frame-into-a-wpf-application.md | 8 +++++--- .../graphics-rendering-registry-settings.md | 5 +++-- .../how-to-apply-emissive-material-to-a-3-d-object.md | 6 ++++-- ...ow-to-apply-multiple-transformations-to-a-3-d-model.md | 6 ++++-- ...rol-a-mediaelement-play-pause-stop-volume-and-speed.md | 5 +++-- .../wpf/graphics-multimedia/how-to-create-a-3-d-scene.md | 6 ++++-- .../how-to-create-a-shape-using-a-streamgeometry.md | 8 +++++--- .../how-to-encode-and-decode-a-bmp-image.md | 6 ++++-- .../how-to-encode-and-decode-a-gif-image.md | 6 ++++-- .../how-to-encode-and-decode-a-png-image.md | 6 ++++-- .../how-to-encode-and-decode-a-tiff-image.md | 6 ++++-- .../how-to-encode-and-decode-a-wdp-image.md | 6 ++++-- .../how-to-load-an-image-as-a-thumbnail.md | 6 ++++-- .../how-to-paint-an-area-with-a-video.md | 6 ++++-- 20 files changed, 78 insertions(+), 42 deletions(-) diff --git a/dotnet-desktop-guide/framework/wpf/controls/how-to-use-a-custom-context-menu-with-a-textbox.md b/dotnet-desktop-guide/framework/wpf/controls/how-to-use-a-custom-context-menu-with-a-textbox.md index 56e32f9..dc982e4 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/how-to-use-a-custom-context-menu-with-a-textbox.md +++ b/dotnet-desktop-guide/framework/wpf/controls/how-to-use-a-custom-context-menu-with-a-textbox.md @@ -1,6 +1,8 @@ --- title: "How to: Use a Custom Context Menu with a TextBox" +description: Learn how to use a Custom Context Menu with a TextBox. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -14,14 +16,14 @@ ms.assetid: 842d3cd5-6fa0-4be4-8d90-6c7466213b1c # How to: Use a Custom Context Menu with a TextBox This example shows how to define and implement a simple custom context menu for a . -## Example +## Define a Custom Context Menu The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] example defines a control that includes a custom context menu. The context menu is defined using a element. The context menu itself consists of a series of elements and elements. Each element defines a command in the context menu; the attribute defines the display text for the menu command, and the attribute specifies a handler method for each menu item. The element simply causes a separating line to be rendered between the previous and subsequent menu items. [!code-xaml[TextBox_ContextMenu#_TextBox_ContextMenuXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_ContextMenu/CSharp/Window1.xaml#_textbox_contextmenuxaml)] -## Example +## Implement a Custom Context Menu The following example shows the implementation code for the preceding context menu definition, as well as the code that enables and disables the context menu. The event is used to dynamically enable or disable certain commands depending on the current state of the . To restore the default context menu, use the method to clear the value of the property. To disable the context menu altogether, set the property to a null reference (`Nothing` in Visual Basic). diff --git a/dotnet-desktop-guide/framework/wpf/controls/how-to-use-spell-checking-with-a-context-menu.md b/dotnet-desktop-guide/framework/wpf/controls/how-to-use-spell-checking-with-a-context-menu.md index 58ede1e..dc36449 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/how-to-use-spell-checking-with-a-context-menu.md +++ b/dotnet-desktop-guide/framework/wpf/controls/how-to-use-spell-checking-with-a-context-menu.md @@ -1,6 +1,8 @@ --- title: "How to: Use Spell Checking with a Context Menu" +description: Learn how to use Spell Checking with a Context Menu. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -13,12 +15,12 @@ ms.assetid: 61f69a20-2ff3-4056-9060-e32f4483ec5e # How to: Use Spell Checking with a Context Menu By default, when you enable spell checking in an editing control like or , you get spell-checking choices in the context menu. For example, when users right-click a misspelled word, they get a set of spelling suggestions or the option to **Ignore All**. However, when you override the default context menu with your own custom context menu, this functionality is lost, and you need to write code to reenable the spell-checking feature in the context menu. The following example shows how to enable this on a . -## Example +## Define a Context Menu The following example shows the [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] that creates a with some events that are used to implement the context menu. [!code-xaml[TextBoxMiscSnippets_snip#SpellerCustomContextMenuExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBoxMiscSnippets_snip/csharp/speller_custom_context_menu.xaml#spellercustomcontextmenuexamplewholepage)] -## Example +## Implement a Context Menu The following example shows the code that implements the context menu. [!code-csharp[TextBoxMiscSnippets_snip#SpellerCustomContextMenuCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBoxMiscSnippets_snip/csharp/speller_custom_context_menu.xaml.cs#spellercustomcontextmenucodeexamplewholepage)] diff --git a/dotnet-desktop-guide/framework/wpf/controls/how-to-use-the-image-element.md b/dotnet-desktop-guide/framework/wpf/controls/how-to-use-the-image-element.md index f92cd51..45613ad 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/how-to-use-the-image-element.md +++ b/dotnet-desktop-guide/framework/wpf/controls/how-to-use-the-image-element.md @@ -1,6 +1,8 @@ --- title: "How to: Use the Image Element" +description: Learn how to use the Image Element. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -13,7 +15,7 @@ ms.assetid: 5b92e74b-1b56-4756-ac64-d5e9e08d9854 # How to: Use the Image Element This example shows how to include images in an application by using the element. -## Example +## Define an image The following example shows how to render an image 200 pixels wide. In this [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] example, both attribute syntax and property tag syntax are used to define the image. For more information on attribute syntax and property syntax, see [Dependency Properties Overview](../advanced/dependency-properties-overview.md). A is used to define the image's source data and is explicitly defined for the property tag syntax example. In addition, the of the is set to the same width as the of the . This is done to ensure that the minimum amount of memory is used rendering the image. > [!NOTE] @@ -26,7 +28,7 @@ This example shows how to include images in an application by using the [!NOTE] diff --git a/dotnet-desktop-guide/framework/wpf/controls/position-the-cursor-at-the-beginning-or-end-of-text.md b/dotnet-desktop-guide/framework/wpf/controls/position-the-cursor-at-the-beginning-or-end-of-text.md index d0e9e68..2102f9f 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/position-the-cursor-at-the-beginning-or-end-of-text.md +++ b/dotnet-desktop-guide/framework/wpf/controls/position-the-cursor-at-the-beginning-or-end-of-text.md @@ -2,6 +2,7 @@ title: "How to: Position the Cursor at the Beginning or End of Text in a TextBox Control" description: Learn how to position the cursor at the beginning or end of the text contents of a Windows Presentation Foundation TextBox control. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -14,18 +15,18 @@ ms.assetid: c771a0b8-c6b4-4240-aecd-a21d0ba51a2e # How to: Position the Cursor at the Beginning or End of Text in a TextBox Control This example shows how to position the cursor at the beginning or end of the text contents of a control. -## Example +## Define a TextBox control The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] code describes a control and assigns it a Name. [!code-xaml[TextBox_MiscCode#_MoveCursorXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_movecursorxaml)] -## Example +## Position the cursor at the beginning To position the cursor at the beginning of the contents of a control, call the method and specify the selection start position of 0, and a selection length of 0. [!code-csharp[TextBox_MiscCode#_CursorToStart](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml.cs#_cursortostart)] [!code-vb[TextBox_MiscCode#_CursorToStart](~/samples/snippets/visualbasic/VS_Snippets_Wpf/TextBox_MiscCode/VisualBasic/Window1.xaml.vb#_cursortostart)] -## Example +## Position the cursor at the end To position the cursor at the end of the contents of a control, call the method and specify the selection start position equal to the length of the text content, and a selection length of 0. [!code-csharp[TextBox_MiscCode#_CursorToEnd](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml.cs#_cursortoend)] diff --git a/dotnet-desktop-guide/framework/wpf/controls/statusbar-styles-and-templates.md b/dotnet-desktop-guide/framework/wpf/controls/statusbar-styles-and-templates.md index 040adda..bb9d9ce 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/statusbar-styles-and-templates.md +++ b/dotnet-desktop-guide/framework/wpf/controls/statusbar-styles-and-templates.md @@ -1,6 +1,8 @@ --- title: "StatusBar Styles and Templates" +description: Learn about the StatusBar Styles and Templates. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 helpviewer_keywords: - "ControlTemplate [WPF], StatusBar" - "styles [WPF], StatusBar" @@ -28,7 +30,7 @@ This topic describes the styles and templates for the control does not have any named parts. -## StatusBar States +## StatusBarItem States The following table lists the visual states for the control. |VisualState Name|VisualStateGroup Name|Description| diff --git a/dotnet-desktop-guide/framework/wpf/getting-started/index.md b/dotnet-desktop-guide/framework/wpf/getting-started/index.md index 42fcb5e..2470b99 100644 --- a/dotnet-desktop-guide/framework/wpf/getting-started/index.md +++ b/dotnet-desktop-guide/framework/wpf/getting-started/index.md @@ -2,6 +2,7 @@ title: "Getting Started" description: Create desktop client applications with the UI framework of Windows Presentation Foundation (WPF), a subset of the .NET Framework. ms.date: "01/26/2018" +ms.custom: devdivchpfy22 helpviewer_keywords: - "getting started [WPF]" - "introduction [WPF]" @@ -14,8 +15,8 @@ Windows Presentation Foundation (WPF) is a UI framework that creates desktop cli ## Where should I start? -||| -|-|-| +| Action | Go to | +|--------|-------| |I want to jump right in…|[Walkthrough: My first WPF desktop application](walkthrough-my-first-wpf-desktop-application.md)| |How do I design the application UI?|[Designing XAML in Visual Studio](/visualstudio/designers/designing-xaml-in-visual-studio)| |New to .NET?|[Overview of the .NET Framework](/dotnet/framework/get-started/overview)

[Getting Started with Visual C# and Visual Basic](/visualstudio/ide/quickstart-visual-basic-console)| diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/extend-glass-frame-into-a-wpf-application.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/extend-glass-frame-into-a-wpf-application.md index 6bd8fd1..6b049c7 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/extend-glass-frame-into-a-wpf-application.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/extend-glass-frame-into-a-wpf-application.md @@ -1,7 +1,9 @@ --- title: "Extend Glass Frame Into a WPF app" titleSuffix: "" +description: Learn about how to Extend Glass Frame into a WPF app. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -20,7 +22,7 @@ This topic demonstrates how to extend the Windows Vista glass frame into the cli > [!NOTE] > This example will only work on a Windows Vista machine running the Desktop Window Manager (DWM) with glass enabled. Windows Vista Home Basic edition does not support the transparent glass effect. Areas that would typically render with the transparent glass effect on other editions of Windows Vista are rendered opaque. -## Example +## Extended Glass Frame in an address bar The following image illustrates the glass frame extended into the address bar of Internet Explorer 7: @@ -60,7 +62,7 @@ End Function [DwmExtendFrameIntoClientArea](/windows/desktop/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea) is the DWM function that extends the frame into the client area. It takes two parameters; a window handle and a [MARGINS](/windows/win32/api/uxtheme/ns-uxtheme-margins) structure. [MARGINS](/windows/win32/api/uxtheme/ns-uxtheme-margins) is used to tell the DWM how much extra the frame should be extended into the client area. -## Example +## Extended Glass Frame on the Loaded event To use the [DwmExtendFrameIntoClientArea](/windows/desktop/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea) function, a window handle must be obtained. In WPF, the window handle can be obtained from the property of an . In the following example, the frame is extended into the client area on the event of the window. @@ -105,7 +107,7 @@ void OnLoaded(object sender, RoutedEventArgs e) } ``` -## Example +## Extended Glass Frame in client area The following example shows a simple window in which the frame is extended into the client area. The frame is extended behind the top border that contains the two objects. diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/graphics-rendering-registry-settings.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/graphics-rendering-registry-settings.md index ee43a93..13e8247 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/graphics-rendering-registry-settings.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/graphics-rendering-registry-settings.md @@ -2,6 +2,7 @@ title: "Graphics Rendering Registry Settings" description: Find out how to use registry settings for troubleshooting, debugging, and product support purposes in the Windows Presentation Foundation (WPF). ms.date: "03/30/2017" +ms.custom: devdivchpfy22 helpviewer_keywords: - "rendering graphics [WPF], registry settings" - "rendering graphics [WPF]" @@ -71,8 +72,8 @@ This topic provides an overview of the [!INCLUDE[TLA2#tla_winclient](../../../in The required video driver setting takes a string of the following format: -| | -|-| +| String format | +|---------------| |*YYYY* `/` *MM* `/` *DD*| Where *YYYY* is the four-digit year, *MM* is the two-digit month, and *DD* is the two digit day. When this value is unset, [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] uses November, 2004 as its required video driver date. diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-apply-emissive-material-to-a-3-d-object.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-apply-emissive-material-to-a-3-d-object.md index 1b9248b..e2d05ef 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-apply-emissive-material-to-a-3-d-object.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-apply-emissive-material-to-a-3-d-object.md @@ -1,6 +1,8 @@ --- title: "How to: Apply Emissive Material to a 3D Object" +description: Learn how to apply Emissive Material to a 3D object. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -19,12 +21,12 @@ The following example shows how to use . The example creates a simple media player that allows you to play, pause, stop, and skip back and forth in the media as well as adjust the volume and speed ratio. -## Example +## Create the UI The code below creates the UI. > [!NOTE] @@ -23,7 +24,7 @@ The following example shows how to control playback of media using a , , and methods are used to respectively play, pause and stop the media. Changing the property of the allows you to skip around in the media. Finally, the and properties are used to adjust the volume and playback speed of the media. [!code-csharp[MediaGallery_snip#CodeBehindMediaElementExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/MediaGallery_snip/CSharp/MediaElementExample.xaml.cs#codebehindmediaelementexamplewholepage)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-3-d-scene.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-3-d-scene.md index 3cf5792..1660b0b 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-3-d-scene.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-3-d-scene.md @@ -1,6 +1,8 @@ --- title: "How to: Create a 3D Scene" +description: Learn how to create a 3D scene. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -20,12 +22,12 @@ This example shows how to create a 3D object that looks like a flat sheet of pap - A light is created to shine on the object using . -## Example +## Create a 3D scene in XAML The code below shows how to create a 3D scene in XAML. [!code-xaml[3DGallery_snip#Basic3DShapeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_snip/CS/Basic3DShapeExample.xaml#basic3dshapeexamplewholepage)] -## Example +## Create a 3D scene in procedural code The code below shows how to create the same 3D scene in procedural code. [!code-csharp[3DGallery_procedural_snip#Basic3DShapeCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/Basic3DShapeExample.cs#basic3dshapecodeexamplewholepage)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-shape-using-a-streamgeometry.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-shape-using-a-streamgeometry.md index 5c21a94..c247ec4 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-shape-using-a-streamgeometry.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-shape-using-a-streamgeometry.md @@ -1,6 +1,8 @@ --- title: "How to: Create a Shape Using a StreamGeometry" +description: Learn how to create a Shape using a StreamGeometry. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -12,20 +14,20 @@ ms.assetid: 08f7c8ce-074b-49cd-9aba-cc9592d4ee51 # How to: Create a Shape Using a StreamGeometry is lightweight alternative to for creating geometric shapes. Use a when you need to describe a complex geometry but do not want the overhead of supporting data binding, animation, or modification. For example, because of its efficiency, the class is a good choice for describing adorners. -## Example +## Create a triangular StreamGeometry The following example uses attribute syntax to create a triangular in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)]. [!code-xaml[GeometriesMiscSnippets_snip#StreamGeometryTriangleExampleWholePage](~/samples/snippets/xaml/VS_Snippets_Wpf/GeometriesMiscSnippets_snip/XAML/StreamGeometryExample.xaml#streamgeometrytriangleexamplewholepage)] For more information about attribute syntax, see the [Path Markup Syntax](path-markup-syntax.md) page. -## Example +## Use a StreamGeometry to define a triangle The next example uses a to define a triangle in code. First, the example creates a , then obtains a and uses it to describe the triangle. [!code-csharp[GeometriesMiscSnippets_procedural_snip#StreamGeometryTriangleExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/CSharp/StreamGeometryTriangleExample.cs#streamgeometrytriangleexamplewholepage)] [!code-vb[GeometriesMiscSnippets_procedural_snip#StreamGeometryTriangleExampleWholePage](~/samples/snippets/visualbasic/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/visualbasic/streamgeometrytriangleexample.vb#streamgeometrytriangleexamplewholepage)] -## Example +## Create a geometric shape in code The next example creates a method that uses a and to define a geometric shape based on specified parameters. [!code-csharp[GeometriesMiscSnippets_procedural_snip#StreamGeometryExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/CSharp/StreamGeometryExample.cs#streamgeometryexamplewholepage)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-bmp-image.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-bmp-image.md index 2f1a05a..4466184 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-bmp-image.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-bmp-image.md @@ -1,6 +1,8 @@ --- title: "How to: Encode and Decode a BMP Image" +description: Learn how to Encode and Decode a BMP image. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -17,14 +19,14 @@ ms.assetid: feb5ef27-28ac-40ab-bfc2-e0456990d32c # How to: Encode and Decode a BMP Image The following examples show how to decode and encode a bitmap (BMP) image using the specific and objects. -## Example +## Decode a BMP image This example demonstrates how to decode a BMP image using a from a . [!code-cpp[BmpBitmapDecoderEncoder#5](~/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherfile.cpp#5)] [!code-csharp[BmpBitmapDecoderEncoder#5](~/samples/snippets/csharp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CSharp/BitmapFrame.cs#5)] [!code-vb[BmpBitmapDecoderEncoder#5](~/samples/snippets/visualbasic/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/VB/BitmapFrame.vb#5)] -## Example +## Encode a BMP image This example demonstrates how to encode a into a BMP image using a . [!code-cpp[BmpBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherfile.cpp#4)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-gif-image.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-gif-image.md index 9c5e7d6..9554c08 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-gif-image.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-gif-image.md @@ -1,6 +1,8 @@ --- title: "How to: Encode and Decode a GIF Image" +description: Learn how to Encode and Decode a GIF image. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -17,14 +19,14 @@ ms.assetid: 9cdd9ec7-71eb-444b-b9e3-991958461163 # How to: Encode and Decode a GIF Image The following examples show how to decode and encode a Graphics Interchange Format (GIF) image using the specific and objects. -## Example +## Decode a GIF image This example demonstrates how to decode a GIF image using a from a . [!code-cpp[GifBitmapDecoderEncoder#1](~/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/GifEncoderDecoder.cpp#1)] [!code-csharp[GifBitmapDecoderEncoder#1](~/samples/snippets/csharp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CSharp/GifEncoderDecoder.cs#1)] [!code-vb[GifBitmapDecoderEncoder#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/GifBitmapDecoderEncoder/VB/GifEncoderDecoder.vb#1)] -## Example +## Encode a GIF image This example demonstrates how to encode a into a GIF image using a . [!code-cpp[GifBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/GifEncoderDecoder.cpp#4)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-png-image.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-png-image.md index 15ef790..6291b0f 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-png-image.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-png-image.md @@ -1,6 +1,8 @@ --- title: "How to: Encode and Decode a PNG Image" +description: Learn how to Encode and Decode a PNG image. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -17,14 +19,14 @@ ms.assetid: 3d31d186-af73-47f0-b5a7-c26ae46409a6 # How to: Encode and Decode a PNG Image The following examples show how to decode and encode a Portable Network Graphics (PNG) image using the specific and objects. -## Example +## Decode a PNG image This example demonstrates how to decode a PNG image using a from a . [!code-cpp[PngBitmapDecoderEncoder#1](~/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/PngEncoderDecoder.cpp#1)] [!code-csharp[PngBitmapDecoderEncoder#1](~/samples/snippets/csharp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CSharp/PngEncoderDecoder.cs#1)] [!code-vb[PngBitmapDecoderEncoder#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/PngBitmapDecoderEncoder/VB/PngEncoderDecoder.vb#1)] -## Example +## Encode a PNG image This example demonstrates how to encode a into a PNG image using a . [!code-cpp[PngBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/PngEncoderDecoder.cpp#4)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-tiff-image.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-tiff-image.md index b5c8d7c..1975cdd 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-tiff-image.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-tiff-image.md @@ -1,6 +1,8 @@ --- title: "How to: Encode and Decode a TIFF Image" +description: Learn how to Encode and Decode a TIFF image. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -17,14 +19,14 @@ ms.assetid: 1dfe3209-fc73-40e6-ad1c-71c1c58b3364 # How to: Encode and Decode a TIFF Image The following examples show how to decode and encode a Tagged Image File Format (TIFF) image using the specific and objects. -## Example +## Decode a TIFF image This example demonstrates how to decode a TIFF image using a from a . [!code-cpp[TiffBitmapDecoderEncoder#1](~/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/TiffEncoderDecoder.cpp#1)] [!code-csharp[TiffBitmapDecoderEncoder#1](~/samples/snippets/csharp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CSharp/TiffEncoderDecoder.cs#1)] [!code-vb[TiffBitmapDecoderEncoder#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/VB/TiffEncoderDecoder.vb#1)] -## Example +## Encode a TIFF image This example demonstrates how to encode a into a TIFF image using a . [!code-cpp[TiffBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/TiffEncoderDecoder.cpp#4)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-wdp-image.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-wdp-image.md index f4d5c8f..7eb0b1b 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-wdp-image.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-encode-and-decode-a-wdp-image.md @@ -1,6 +1,8 @@ --- title: "How to: Encode and Decode a WDP Image" +description: Learn how to Encode and Decode a WDP image. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -17,14 +19,14 @@ ms.assetid: 911777d1-516b-49db-a87b-b54e31b18532 # How to: Encode and Decode a WDP Image The following examples show how to decode and encode a Microsoft Windows Media Photo image using the specific and objects. -## Example +## Decode a Windows Media Photo image This example demonstrates how to decode a Windows Media Photo image using a from a . [!code-cpp[WdpBitmapDecoderEncoder#1](~/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/WDPEncoderDecoder.cpp#1)] [!code-csharp[WdpBitmapDecoderEncoder#1](~/samples/snippets/csharp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CSharp/WDPEncoderDecoder.cs#1)] [!code-vb[WdpBitmapDecoderEncoder#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/VB/WDPEncoderDecoder.vb#1)] -## Example +## Encode a Windows Media Photo image This example demonstrates how to encode a into a Windows Media Photo image using a . [!code-cpp[WdpBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/WDPEncoderDecoder.cpp#4)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-load-an-image-as-a-thumbnail.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-load-an-image-as-a-thumbnail.md index 57b6c16..f4ded93 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-load-an-image-as-a-thumbnail.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-load-an-image-as-a-thumbnail.md @@ -1,6 +1,8 @@ --- title: "How to: Load an Image as a Thumbnail" +description: Learn how to Load an Image as a Thumbnail. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -13,12 +15,12 @@ ms.assetid: 02e055a0-54df-499a-b8b6-ab6ff7535cff # How to: Load an Image as a Thumbnail The following examples show how to load an as a thumbnail to conserve application memory. -## Example +## Set the DecodePixelWidth property in XAML The following example sets the property of a in [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] to reduce the memory required to load the image. [!code-xaml[ImageElementExample_snip#ImageSimpleExampleInlineMarkup](~/samples/snippets/csharp/VS_Snippets_Wpf/ImageElementExample_snip/CSharp/ImageSimpleExample.xaml#imagesimpleexampleinlinemarkup)] -## Example +## Set the DecodePixelWidth property in code The following example sets the property of a in code to reduce the memory required to load the image. [!code-csharp[ImageElementExample_snip#ImageSimpleExampleInlineCode1](~/samples/snippets/csharp/VS_Snippets_Wpf/ImageElementExample_snip/CSharp/ImageSimpleExample.xaml.cs#imagesimpleexampleinlinecode1)] diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-paint-an-area-with-a-video.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-paint-an-area-with-a-video.md index c94227d..1a40d88 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-paint-an-area-with-a-video.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-paint-an-area-with-a-video.md @@ -1,6 +1,8 @@ --- title: "How to: Paint an Area with a Video" +description: Learn how to Paint an Area with a Video. ms.date: "03/30/2017" +ms.custom: devdivchpfy22 dev_langs: - "csharp" - "vb" @@ -13,14 +15,14 @@ ms.assetid: 04dd6600-4a6e-4b43-a93e-21cce7dfbcb8 # How to: Paint an Area with a Video This example shows how to paint an area with media. One way to paint an area with media is to use a together with a . Use the to load and play the media, and then use it to set the property of the . You can then use the to paint an area with the loaded media. -## Example +## Use a MediaElement with a VisualBrush The following example uses a and a to paint the of a control with video. This example sets the property of the to `true` so that it produces no sound. [!code-csharp[Visualbrush_markup_snip#GraphicsMMVideoAsTextBackgroundInline](~/samples/snippets/csharp/VS_Snippets_Wpf/visualbrush_markup_snip/CSharp/PaintWithVideoExample.cs#graphicsmmvideoastextbackgroundinline)] [!code-vb[Visualbrush_markup_snip#GraphicsMMVideoAsTextBackgroundInline](~/samples/snippets/visualbasic/VS_Snippets_Wpf/visualbrush_markup_snip/visualbasic/paintwithvideoexample.vb#graphicsmmvideoastextbackgroundinline)] [!code-xaml[Visualbrush_markup_snip#GraphicsMMVideoAsTextBackgroundInline](~/samples/snippets/xaml/VS_Snippets_Wpf/visualbrush_markup_snip/XAML/PaintWithVideoExample.xaml#graphicsmmvideoastextbackgroundinline)] -## Example +## Use the VisualBrush with the loaded media Because inherits from the class, it provides several tiling modes. By setting the property of a to and by setting its property to a value smaller than the area that you are painting, you can create a tiled pattern. The following example is identical to the previous example, except that the generates a pattern from the video.