mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-04 09:06:04 +02:00
Merge pull request #1324 from dotnet/publish-6393
This commit is contained in:
@@ -620,6 +620,14 @@
|
|||||||
{
|
{
|
||||||
"source_path": "dotnet-desktop-guide/framework/wpf/events/how-to-create-a-custom-routed-event.md",
|
"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"
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Use a Custom Context Menu with a TextBox"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -14,14 +16,14 @@ ms.assetid: 842d3cd5-6fa0-4be4-8d90-6c7466213b1c
|
|||||||
# How to: Use a Custom Context Menu with a TextBox
|
# 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 <xref:System.Windows.Controls.TextBox>.
|
This example shows how to define and implement a simple custom context menu for a <xref:System.Windows.Controls.TextBox>.
|
||||||
|
|
||||||
## Example
|
## Define a Custom Context Menu
|
||||||
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] example defines a <xref:System.Windows.Controls.TextBox> control that includes a custom context menu.
|
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] example defines a <xref:System.Windows.Controls.TextBox> control that includes a custom context menu.
|
||||||
|
|
||||||
The context menu is defined using a <xref:System.Windows.Controls.ContextMenu> element. The context menu itself consists of a series of <xref:System.Windows.Controls.MenuItem> elements and <xref:System.Windows.Controls.Separator> elements. Each <xref:System.Windows.Controls.MenuItem> element defines a command in the context menu; the <xref:System.Windows.Controls.HeaderedItemsControl.Header%2A> attribute defines the display text for the menu command, and the <xref:System.Windows.Controls.MenuItem.Click> attribute specifies a handler method for each menu item. The <xref:System.Windows.Controls.Separator> element simply causes a separating line to be rendered between the previous and subsequent menu items.
|
The context menu is defined using a <xref:System.Windows.Controls.ContextMenu> element. The context menu itself consists of a series of <xref:System.Windows.Controls.MenuItem> elements and <xref:System.Windows.Controls.Separator> elements. Each <xref:System.Windows.Controls.MenuItem> element defines a command in the context menu; the <xref:System.Windows.Controls.HeaderedItemsControl.Header%2A> attribute defines the display text for the menu command, and the <xref:System.Windows.Controls.MenuItem.Click> attribute specifies a handler method for each menu item. The <xref:System.Windows.Controls.Separator> 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)]
|
[!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 <xref:System.Windows.Controls.ContextMenu.Opened> event is used to dynamically enable or disable certain commands depending on the current state of the <xref:System.Windows.Controls.TextBox>.
|
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 <xref:System.Windows.Controls.ContextMenu.Opened> event is used to dynamically enable or disable certain commands depending on the current state of the <xref:System.Windows.Controls.TextBox>.
|
||||||
|
|
||||||
To restore the default context menu, use the <xref:System.Windows.DependencyObject.ClearValue%2A> method to clear the value of the <xref:System.Windows.FrameworkElement.ContextMenu%2A> property. To disable the context menu altogether, set the <xref:System.Windows.FrameworkElement.ContextMenu%2A> property to a null reference (`Nothing` in Visual Basic).
|
To restore the default context menu, use the <xref:System.Windows.DependencyObject.ClearValue%2A> method to clear the value of the <xref:System.Windows.FrameworkElement.ContextMenu%2A> property. To disable the context menu altogether, set the <xref:System.Windows.FrameworkElement.ContextMenu%2A> property to a null reference (`Nothing` in Visual Basic).
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Use Spell Checking with a Context Menu"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -13,12 +15,12 @@ ms.assetid: 61f69a20-2ff3-4056-9060-e32f4483ec5e
|
|||||||
# How to: Use Spell Checking with a Context Menu
|
# How to: Use Spell Checking with a Context Menu
|
||||||
By default, when you enable spell checking in an editing control like <xref:System.Windows.Controls.TextBox> or <xref:System.Windows.Controls.RichTextBox>, 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 <xref:System.Windows.Controls.TextBox>.
|
By default, when you enable spell checking in an editing control like <xref:System.Windows.Controls.TextBox> or <xref:System.Windows.Controls.RichTextBox>, 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 <xref:System.Windows.Controls.TextBox>.
|
||||||
|
|
||||||
## Example
|
## Define a Context Menu
|
||||||
The following example shows the [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] that creates a <xref:System.Windows.Controls.TextBox> with some events that are used to implement the context menu.
|
The following example shows the [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] that creates a <xref:System.Windows.Controls.TextBox> 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)]
|
[!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.
|
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)]
|
[!code-csharp[TextBoxMiscSnippets_snip#SpellerCustomContextMenuCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBoxMiscSnippets_snip/csharp/speller_custom_context_menu.xaml.cs#spellercustomcontextmenucodeexamplewholepage)]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Use the Image Element"
|
title: "How to: Use the Image Element"
|
||||||
|
description: Learn how to use the Image Element.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -13,7 +15,7 @@ ms.assetid: 5b92e74b-1b56-4756-ac64-d5e9e08d9854
|
|||||||
# How to: Use the Image Element
|
# How to: Use the Image Element
|
||||||
This example shows how to include images in an application by using the <xref:System.Windows.Controls.Image> element.
|
This example shows how to include images in an application by using the <xref:System.Windows.Controls.Image> 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 <xref:System.Windows.Media.Imaging.BitmapImage> is used to define the image's source data and is explicitly defined for the property tag syntax example. In addition, the <xref:System.Windows.Media.Imaging.BitmapImage.DecodePixelWidth%2A> of the <xref:System.Windows.Media.Imaging.BitmapImage> is set to the same width as the <xref:System.Windows.FrameworkElement.Width%2A> of the <xref:System.Windows.Controls.Image>. This is done to ensure that the minimum amount of memory is used rendering the 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 <xref:System.Windows.Media.Imaging.BitmapImage> is used to define the image's source data and is explicitly defined for the property tag syntax example. In addition, the <xref:System.Windows.Media.Imaging.BitmapImage.DecodePixelWidth%2A> of the <xref:System.Windows.Media.Imaging.BitmapImage> is set to the same width as the <xref:System.Windows.FrameworkElement.Width%2A> of the <xref:System.Windows.Controls.Image>. This is done to ensure that the minimum amount of memory is used rendering the image.
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
@@ -26,7 +28,7 @@ This example shows how to include images in an application by using the <xref:Sy
|
|||||||
|
|
||||||
[!code-xaml[ImageElementExample_snip#ImageSimpleExampleInlineMarkup](~/samples/snippets/csharp/VS_Snippets_Wpf/ImageElementExample_snip/CSharp/ImageSimpleExample.xaml#imagesimpleexampleinlinemarkup)]
|
[!code-xaml[ImageElementExample_snip#ImageSimpleExampleInlineMarkup](~/samples/snippets/csharp/VS_Snippets_Wpf/ImageElementExample_snip/CSharp/ImageSimpleExample.xaml#imagesimpleexampleinlinemarkup)]
|
||||||
|
|
||||||
## Example
|
## Render an image
|
||||||
The following example shows how to render an image 200 pixels wide using code.
|
The following example shows how to render an image 200 pixels wide using code.
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
|
|||||||
+4
-3
@@ -2,6 +2,7 @@
|
|||||||
title: "How to: Position the Cursor at the Beginning or End of Text in a TextBox Control"
|
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.
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "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
|
# 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 <xref:System.Windows.Controls.TextBox> control.
|
This example shows how to position the cursor at the beginning or end of the text contents of a <xref:System.Windows.Controls.TextBox> control.
|
||||||
|
|
||||||
## Example
|
## Define a TextBox control
|
||||||
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] code describes a <xref:System.Windows.Controls.TextBox> control and assigns it a Name.
|
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] code describes a <xref:System.Windows.Controls.TextBox> control and assigns it a Name.
|
||||||
|
|
||||||
[!code-xaml[TextBox_MiscCode#_MoveCursorXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_movecursorxaml)]
|
[!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 <xref:System.Windows.Controls.TextBox> control, call the <xref:System.Windows.Controls.TextBox.Select%2A> method and specify the selection start position of 0, and a selection length of 0.
|
To position the cursor at the beginning of the contents of a <xref:System.Windows.Controls.TextBox> control, call the <xref:System.Windows.Controls.TextBox.Select%2A> 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-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)]
|
[!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 <xref:System.Windows.Controls.TextBox> control, call the <xref:System.Windows.Controls.TextBox.Select%2A> method and specify the selection start position equal to the length of the text content, and a selection length of 0.
|
To position the cursor at the end of the contents of a <xref:System.Windows.Controls.TextBox> control, call the <xref:System.Windows.Controls.TextBox.Select%2A> 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)]
|
[!code-csharp[TextBox_MiscCode#_CursorToEnd](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml.cs#_cursortoend)]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "StatusBar Styles and Templates"
|
title: "StatusBar Styles and Templates"
|
||||||
|
description: Learn about the StatusBar Styles and Templates.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
helpviewer_keywords:
|
helpviewer_keywords:
|
||||||
- "ControlTemplate [WPF], StatusBar"
|
- "ControlTemplate [WPF], StatusBar"
|
||||||
- "styles [WPF], StatusBar"
|
- "styles [WPF], StatusBar"
|
||||||
@@ -28,7 +30,7 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
|||||||
## StatusBarItem Parts
|
## StatusBarItem Parts
|
||||||
The <xref:System.Windows.Controls.Primitives.StatusBarItem> control does not have any named parts.
|
The <xref:System.Windows.Controls.Primitives.StatusBarItem> control does not have any named parts.
|
||||||
|
|
||||||
## StatusBar States
|
## StatusBarItem States
|
||||||
The following table lists the visual states for the <xref:System.Windows.Controls.Primitives.StatusBarItem> control.
|
The following table lists the visual states for the <xref:System.Windows.Controls.Primitives.StatusBarItem> control.
|
||||||
|
|
||||||
|VisualState Name|VisualStateGroup Name|Description|
|
|VisualState Name|VisualStateGroup Name|Description|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
title: "Getting Started"
|
title: "Getting Started"
|
||||||
description: Create desktop client applications with the UI framework of Windows Presentation Foundation (WPF), a subset of the .NET Framework.
|
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.date: "01/26/2018"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
helpviewer_keywords:
|
helpviewer_keywords:
|
||||||
- "getting started [WPF]"
|
- "getting started [WPF]"
|
||||||
- "introduction [WPF]"
|
- "introduction [WPF]"
|
||||||
@@ -14,8 +15,8 @@ Windows Presentation Foundation (WPF) is a UI framework that creates desktop cli
|
|||||||
|
|
||||||
## Where should I start?
|
## 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)|
|
|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)|
|
|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)<br /><br /> [Getting Started with Visual C# and Visual Basic](/visualstudio/ide/quickstart-visual-basic-console)|
|
|New to .NET?|[Overview of the .NET Framework](/dotnet/framework/get-started/overview)<br /><br /> [Getting Started with Visual C# and Visual Basic](/visualstudio/ide/quickstart-visual-basic-console)|
|
||||||
|
|||||||
+5
-3
@@ -1,7 +1,9 @@
|
|||||||
---
|
---
|
||||||
title: "Extend Glass Frame Into a WPF app"
|
title: "Extend Glass Frame Into a WPF app"
|
||||||
titleSuffix: ""
|
titleSuffix: ""
|
||||||
|
description: Learn about how to Extend Glass Frame into a WPF app.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -20,7 +22,7 @@ This topic demonstrates how to extend the Windows Vista glass frame into the cli
|
|||||||
> [!NOTE]
|
> [!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.
|
> 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:
|
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.
|
[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 <xref:System.Windows.Interop.HwndSource.Handle%2A> property of an <xref:System.Windows.Interop.HwndSource>. In the following example, the frame is extended into the client area on the <xref:System.Windows.FrameworkElement.Loaded> event of the window.
|
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 <xref:System.Windows.Interop.HwndSource.Handle%2A> property of an <xref:System.Windows.Interop.HwndSource>. In the following example, the frame is extended into the client area on the <xref:System.Windows.FrameworkElement.Loaded> 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 <xref:System.Windows.Controls.TextBox> objects.
|
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 <xref:System.Windows.Controls.TextBox> objects.
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -2,6 +2,7 @@
|
|||||||
title: "Graphics Rendering Registry Settings"
|
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).
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
helpviewer_keywords:
|
helpviewer_keywords:
|
||||||
- "rendering graphics [WPF], registry settings"
|
- "rendering graphics [WPF], registry settings"
|
||||||
- "rendering graphics [WPF]"
|
- "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:
|
The required video driver setting takes a string of the following format:
|
||||||
|
|
||||||
| |
|
| String format |
|
||||||
|-|
|
|---------------|
|
||||||
|*YYYY* `/` *MM* `/` *DD*|
|
|*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.
|
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.
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Apply Emissive Material to a 3D Object"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -19,12 +21,12 @@ The following example shows how to use <xref:System.Windows.Media.Media3D.Emissi
|
|||||||
[!code-csharp[3DGallery_procedural_snip#EmissiveMaterialCodeExampleInline1](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/EmissiveMaterialExample.cs#emissivematerialcodeexampleinline1)]
|
[!code-csharp[3DGallery_procedural_snip#EmissiveMaterialCodeExampleInline1](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/EmissiveMaterialExample.cs#emissivematerialcodeexampleinline1)]
|
||||||
[!code-vb[3DGallery_procedural_snip#EmissiveMaterialCodeExampleInline1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/3DGallery_procedural_snip/visualbasic/emissivematerialexample.vb#emissivematerialcodeexampleinline1)]
|
[!code-vb[3DGallery_procedural_snip#EmissiveMaterialCodeExampleInline1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/3DGallery_procedural_snip/visualbasic/emissivematerialexample.vb#emissivematerialcodeexampleinline1)]
|
||||||
|
|
||||||
## Example
|
## Sample in XAML
|
||||||
The following code shows the entire sample in XAML.
|
The following code shows the entire sample in XAML.
|
||||||
|
|
||||||
[!code-xaml[3DGallery_snip#EmissiveMaterialExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_snip/CS/EmissiveMaterialExample.xaml#emissivematerialexamplewholepage)]
|
[!code-xaml[3DGallery_snip#EmissiveMaterialExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_snip/CS/EmissiveMaterialExample.xaml#emissivematerialexamplewholepage)]
|
||||||
|
|
||||||
## Example
|
## Sample in procedural code
|
||||||
Below is the entire sample in procedural code.
|
Below is the entire sample in procedural code.
|
||||||
|
|
||||||
[!code-csharp[3DGallery_procedural_snip#EmissiveMaterialCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/EmissiveMaterialExample.cs#emissivematerialcodeexamplewholepage)]
|
[!code-csharp[3DGallery_procedural_snip#EmissiveMaterialCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/EmissiveMaterialExample.cs#emissivematerialcodeexamplewholepage)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Apply Multiple Transformations to a 3D Model"
|
title: "How to: Apply Multiple Transformations to a 3D Model"
|
||||||
|
description: Learn how to apply Multiple Transformations to a 3D Model.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -18,12 +20,12 @@ This sample shows how to use a <xref:System.Windows.Media.Media3D.RotateTransfor
|
|||||||
[!code-csharp[3DGallery_procedural_snip#Multiple3DTransformationsCodeExampleInline1](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/MultipleTransformationsExample.cs#multiple3dtransformationscodeexampleinline1)]
|
[!code-csharp[3DGallery_procedural_snip#Multiple3DTransformationsCodeExampleInline1](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/MultipleTransformationsExample.cs#multiple3dtransformationscodeexampleinline1)]
|
||||||
[!code-vb[3DGallery_procedural_snip#Multiple3DTransformationsCodeExampleInline1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/3DGallery_procedural_snip/visualbasic/multipletransformationsexample.vb#multiple3dtransformationscodeexampleinline1)]
|
[!code-vb[3DGallery_procedural_snip#Multiple3DTransformationsCodeExampleInline1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/3DGallery_procedural_snip/visualbasic/multipletransformationsexample.vb#multiple3dtransformationscodeexampleinline1)]
|
||||||
|
|
||||||
## Example
|
## XAML sample
|
||||||
The following code shows the entire sample in XAML.
|
The following code shows the entire sample in XAML.
|
||||||
|
|
||||||
[!code-xaml[3DGallery_snip#Multiple3DTransformationsExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_snip/CS/MultipleTransformationsExample.xaml#multiple3dtransformationsexamplewholepage)]
|
[!code-xaml[3DGallery_snip#Multiple3DTransformationsExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_snip/CS/MultipleTransformationsExample.xaml#multiple3dtransformationsexamplewholepage)]
|
||||||
|
|
||||||
## Example
|
## Procedural sample code
|
||||||
Below is the entire sample in code.
|
Below is the entire sample in code.
|
||||||
|
|
||||||
[!code-csharp[3DGallery_procedural_snip#Multiple3DTransformationsCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/MultipleTransformationsExample.cs#multiple3dtransformationscodeexamplewholepage)]
|
[!code-csharp[3DGallery_procedural_snip#Multiple3DTransformationsCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/MultipleTransformationsExample.cs#multiple3dtransformationscodeexamplewholepage)]
|
||||||
|
|||||||
+3
-2
@@ -2,6 +2,7 @@
|
|||||||
title: "How to: Control a MediaElement (Play, Pause, Stop, Volume, and Speed)"
|
title: "How to: Control a MediaElement (Play, Pause, Stop, Volume, and Speed)"
|
||||||
description: Control playback of media in Windows Presentation foundation (WPF). Start, stop, pause, skip back and forth, and adjust volume and speed.
|
description: Control playback of media in Windows Presentation foundation (WPF). Start, stop, pause, skip back and forth, and adjust volume and speed.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -15,7 +16,7 @@ ms.assetid: 6885a730-e054-4c16-8c1e-ffe17b1f7c32
|
|||||||
# How to: Control a MediaElement (Play, Pause, Stop, Volume, and Speed)
|
# How to: Control a MediaElement (Play, Pause, Stop, Volume, and Speed)
|
||||||
The following example shows how to control playback of media using a <xref:System.Windows.Controls.MediaElement>. 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.
|
The following example shows how to control playback of media using a <xref:System.Windows.Controls.MediaElement>. 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.
|
The code below creates the UI.
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
@@ -23,7 +24,7 @@ The following example shows how to control playback of media using a <xref:Syste
|
|||||||
|
|
||||||
[!code-xaml[MediaGallery_snip#MediaElementExampleWholePage](~/samples/snippets/visualbasic/VS_Snippets_Wpf/MediaGallery_snip/VB/MediaElementExample.xaml#mediaelementexamplewholepage)]
|
[!code-xaml[MediaGallery_snip#MediaElementExampleWholePage](~/samples/snippets/visualbasic/VS_Snippets_Wpf/MediaGallery_snip/VB/MediaElementExample.xaml#mediaelementexamplewholepage)]
|
||||||
|
|
||||||
## Example
|
## Implement the UI control
|
||||||
The code below implements the functionality of the sample UI controls. The <xref:System.Windows.Controls.MediaElement.Play%2A>, <xref:System.Windows.Controls.MediaElement.Pause%2A>, and <xref:System.Windows.Controls.MediaElement.Stop%2A> methods are used to respectively play, pause and stop the media. Changing the <xref:System.Windows.Controls.MediaElement.Position%2A> property of the <xref:System.Windows.Controls.MediaElement> allows you to skip around in the media. Finally, the <xref:System.Windows.Controls.MediaElement.Volume%2A> and <xref:System.Windows.Controls.MediaElement.SpeedRatio%2A> properties are used to adjust the volume and playback speed of the media.
|
The code below implements the functionality of the sample UI controls. The <xref:System.Windows.Controls.MediaElement.Play%2A>, <xref:System.Windows.Controls.MediaElement.Pause%2A>, and <xref:System.Windows.Controls.MediaElement.Stop%2A> methods are used to respectively play, pause and stop the media. Changing the <xref:System.Windows.Controls.MediaElement.Position%2A> property of the <xref:System.Windows.Controls.MediaElement> allows you to skip around in the media. Finally, the <xref:System.Windows.Controls.MediaElement.Volume%2A> and <xref:System.Windows.Controls.MediaElement.SpeedRatio%2A> 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)]
|
[!code-csharp[MediaGallery_snip#CodeBehindMediaElementExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/MediaGallery_snip/CSharp/MediaElementExample.xaml.cs#codebehindmediaelementexamplewholepage)]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Create a 3D Scene"
|
title: "How to: Create a 3D Scene"
|
||||||
|
description: Learn how to create a 3D scene.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "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 <xref:System.Windows.Media.Media3D.DirectionalLight>.
|
- A light is created to shine on the object using <xref:System.Windows.Media.Media3D.DirectionalLight>.
|
||||||
|
|
||||||
## Example
|
## Create a 3D scene in XAML
|
||||||
The code below shows how to 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)]
|
[!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.
|
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)]
|
[!code-csharp[3DGallery_procedural_snip#Basic3DShapeCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/3DGallery_procedural_snip/CSharp/Basic3DShapeExample.cs#basic3dshapecodeexamplewholepage)]
|
||||||
|
|||||||
+5
-3
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Create a Shape Using a StreamGeometry"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -12,20 +14,20 @@ ms.assetid: 08f7c8ce-074b-49cd-9aba-cc9592d4ee51
|
|||||||
# How to: Create a Shape Using a StreamGeometry
|
# How to: Create a Shape Using a StreamGeometry
|
||||||
<xref:System.Windows.Media.StreamGeometry> is lightweight alternative to <xref:System.Windows.Media.PathGeometry> for creating geometric shapes. Use a <xref:System.Windows.Media.StreamGeometry> 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 <xref:System.Windows.Media.StreamGeometry> class is a good choice for describing adorners.
|
<xref:System.Windows.Media.StreamGeometry> is lightweight alternative to <xref:System.Windows.Media.PathGeometry> for creating geometric shapes. Use a <xref:System.Windows.Media.StreamGeometry> 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 <xref:System.Windows.Media.StreamGeometry> class is a good choice for describing adorners.
|
||||||
|
|
||||||
## Example
|
## Create a triangular StreamGeometry
|
||||||
The following example uses attribute syntax to create a triangular <xref:System.Windows.Media.StreamGeometry> in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)].
|
The following example uses attribute syntax to create a triangular <xref:System.Windows.Media.StreamGeometry> 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)]
|
[!code-xaml[GeometriesMiscSnippets_snip#StreamGeometryTriangleExampleWholePage](~/samples/snippets/xaml/VS_Snippets_Wpf/GeometriesMiscSnippets_snip/XAML/StreamGeometryExample.xaml#streamgeometrytriangleexamplewholepage)]
|
||||||
|
|
||||||
For more information about <xref:System.Windows.Media.StreamGeometry> attribute syntax, see the [Path Markup Syntax](path-markup-syntax.md) page.
|
For more information about <xref:System.Windows.Media.StreamGeometry> 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 <xref:System.Windows.Media.StreamGeometry> to define a triangle in code. First, the example creates a <xref:System.Windows.Media.StreamGeometry>, then obtains a <xref:System.Windows.Media.StreamGeometryContext> and uses it to describe the triangle.
|
The next example uses a <xref:System.Windows.Media.StreamGeometry> to define a triangle in code. First, the example creates a <xref:System.Windows.Media.StreamGeometry>, then obtains a <xref:System.Windows.Media.StreamGeometryContext> 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-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)]
|
[!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 <xref:System.Windows.Media.StreamGeometry> and <xref:System.Windows.Media.StreamGeometryContext> to define a geometric shape based on specified parameters.
|
The next example creates a method that uses a <xref:System.Windows.Media.StreamGeometry> and <xref:System.Windows.Media.StreamGeometryContext> 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)]
|
[!code-csharp[GeometriesMiscSnippets_procedural_snip#StreamGeometryExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/CSharp/StreamGeometryExample.cs#streamgeometryexamplewholepage)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Encode and Decode a BMP Image"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -17,14 +19,14 @@ ms.assetid: feb5ef27-28ac-40ab-bfc2-e0456990d32c
|
|||||||
# How to: Encode and Decode a BMP Image
|
# How to: Encode and Decode a BMP Image
|
||||||
The following examples show how to decode and encode a bitmap (BMP) image using the specific <xref:System.Windows.Media.Imaging.BmpBitmapDecoder> and <xref:System.Windows.Media.Imaging.BmpBitmapEncoder> objects.
|
The following examples show how to decode and encode a bitmap (BMP) image using the specific <xref:System.Windows.Media.Imaging.BmpBitmapDecoder> and <xref:System.Windows.Media.Imaging.BmpBitmapEncoder> objects.
|
||||||
|
|
||||||
## Example
|
## Decode a BMP image
|
||||||
This example demonstrates how to decode a BMP image using a <xref:System.Windows.Media.Imaging.BmpBitmapDecoder> from a <xref:System.Uri>.
|
This example demonstrates how to decode a BMP image using a <xref:System.Windows.Media.Imaging.BmpBitmapDecoder> from a <xref:System.Uri>.
|
||||||
|
|
||||||
[!code-cpp[BmpBitmapDecoderEncoder#5](~/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherfile.cpp#5)]
|
[!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-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)]
|
[!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 <xref:System.Windows.Media.Imaging.BitmapSource> into a BMP image using a <xref:System.Windows.Media.Imaging.BmpBitmapEncoder>.
|
This example demonstrates how to encode a <xref:System.Windows.Media.Imaging.BitmapSource> into a BMP image using a <xref:System.Windows.Media.Imaging.BmpBitmapEncoder>.
|
||||||
|
|
||||||
[!code-cpp[BmpBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherfile.cpp#4)]
|
[!code-cpp[BmpBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/BmpBitmapDecoderEncoder/CPP/anotherfile.cpp#4)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Encode and Decode a GIF Image"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -17,14 +19,14 @@ ms.assetid: 9cdd9ec7-71eb-444b-b9e3-991958461163
|
|||||||
# How to: Encode and Decode a GIF Image
|
# 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 <xref:System.Windows.Media.Imaging.GifBitmapDecoder> and <xref:System.Windows.Media.Imaging.GifBitmapEncoder> objects.
|
The following examples show how to decode and encode a Graphics Interchange Format (GIF) image using the specific <xref:System.Windows.Media.Imaging.GifBitmapDecoder> and <xref:System.Windows.Media.Imaging.GifBitmapEncoder> objects.
|
||||||
|
|
||||||
## Example
|
## Decode a GIF image
|
||||||
This example demonstrates how to decode a GIF image using a <xref:System.Windows.Media.Imaging.GifBitmapDecoder> from a <xref:System.IO.FileStream>.
|
This example demonstrates how to decode a GIF image using a <xref:System.Windows.Media.Imaging.GifBitmapDecoder> from a <xref:System.IO.FileStream>.
|
||||||
|
|
||||||
[!code-cpp[GifBitmapDecoderEncoder#1](~/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/GifEncoderDecoder.cpp#1)]
|
[!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-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)]
|
[!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 <xref:System.Windows.Media.Imaging.BitmapSource> into a GIF image using a <xref:System.Windows.Media.Imaging.GifBitmapEncoder>.
|
This example demonstrates how to encode a <xref:System.Windows.Media.Imaging.BitmapSource> into a GIF image using a <xref:System.Windows.Media.Imaging.GifBitmapEncoder>.
|
||||||
|
|
||||||
[!code-cpp[GifBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/GifEncoderDecoder.cpp#4)]
|
[!code-cpp[GifBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/GifBitmapDecoderEncoder/CPP/GifEncoderDecoder.cpp#4)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Encode and Decode a PNG Image"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -17,14 +19,14 @@ ms.assetid: 3d31d186-af73-47f0-b5a7-c26ae46409a6
|
|||||||
# How to: Encode and Decode a PNG Image
|
# 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 <xref:System.Windows.Media.Imaging.PngBitmapDecoder> and <xref:System.Windows.Media.Imaging.PngBitmapEncoder> objects.
|
The following examples show how to decode and encode a Portable Network Graphics (PNG) image using the specific <xref:System.Windows.Media.Imaging.PngBitmapDecoder> and <xref:System.Windows.Media.Imaging.PngBitmapEncoder> objects.
|
||||||
|
|
||||||
## Example
|
## Decode a PNG image
|
||||||
This example demonstrates how to decode a PNG image using a <xref:System.Windows.Media.Imaging.PngBitmapDecoder> from a <xref:System.IO.FileStream>.
|
This example demonstrates how to decode a PNG image using a <xref:System.Windows.Media.Imaging.PngBitmapDecoder> from a <xref:System.IO.FileStream>.
|
||||||
|
|
||||||
[!code-cpp[PngBitmapDecoderEncoder#1](~/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/PngEncoderDecoder.cpp#1)]
|
[!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-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)]
|
[!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 <xref:System.Windows.Media.Imaging.BitmapSource> into a PNG image using a <xref:System.Windows.Media.Imaging.PngBitmapEncoder>.
|
This example demonstrates how to encode a <xref:System.Windows.Media.Imaging.BitmapSource> into a PNG image using a <xref:System.Windows.Media.Imaging.PngBitmapEncoder>.
|
||||||
|
|
||||||
[!code-cpp[PngBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/PngEncoderDecoder.cpp#4)]
|
[!code-cpp[PngBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/PngBitmapDecoderEncoder/CPP/PngEncoderDecoder.cpp#4)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Encode and Decode a TIFF Image"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -17,14 +19,14 @@ ms.assetid: 1dfe3209-fc73-40e6-ad1c-71c1c58b3364
|
|||||||
# How to: Encode and Decode a TIFF Image
|
# 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 <xref:System.Windows.Media.Imaging.TiffBitmapDecoder> and <xref:System.Windows.Media.Imaging.TiffBitmapEncoder> objects.
|
The following examples show how to decode and encode a Tagged Image File Format (TIFF) image using the specific <xref:System.Windows.Media.Imaging.TiffBitmapDecoder> and <xref:System.Windows.Media.Imaging.TiffBitmapEncoder> objects.
|
||||||
|
|
||||||
## Example
|
## Decode a TIFF image
|
||||||
This example demonstrates how to decode a TIFF image using a <xref:System.Windows.Media.Imaging.TiffBitmapDecoder> from a <xref:System.Uri>.
|
This example demonstrates how to decode a TIFF image using a <xref:System.Windows.Media.Imaging.TiffBitmapDecoder> from a <xref:System.Uri>.
|
||||||
|
|
||||||
[!code-cpp[TiffBitmapDecoderEncoder#1](~/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/TiffEncoderDecoder.cpp#1)]
|
[!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-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)]
|
[!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 <xref:System.Windows.Media.Imaging.BitmapSource> into a TIFF image using a <xref:System.Windows.Media.Imaging.TiffBitmapEncoder>.
|
This example demonstrates how to encode a <xref:System.Windows.Media.Imaging.BitmapSource> into a TIFF image using a <xref:System.Windows.Media.Imaging.TiffBitmapEncoder>.
|
||||||
|
|
||||||
[!code-cpp[TiffBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/TiffEncoderDecoder.cpp#4)]
|
[!code-cpp[TiffBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/TiffBitmapDecoderEncoder/CPP/TiffEncoderDecoder.cpp#4)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Encode and Decode a WDP Image"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -17,14 +19,14 @@ ms.assetid: 911777d1-516b-49db-a87b-b54e31b18532
|
|||||||
# How to: Encode and Decode a WDP Image
|
# 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 <xref:System.Windows.Media.Imaging.WmpBitmapDecoder> and <xref:System.Windows.Media.Imaging.WmpBitmapEncoder> objects.
|
The following examples show how to decode and encode a Microsoft Windows Media Photo image using the specific <xref:System.Windows.Media.Imaging.WmpBitmapDecoder> and <xref:System.Windows.Media.Imaging.WmpBitmapEncoder> objects.
|
||||||
|
|
||||||
## Example
|
## Decode a Windows Media Photo image
|
||||||
This example demonstrates how to decode a Windows Media Photo image using a <xref:System.Windows.Media.Imaging.WmpBitmapDecoder> from a <xref:System.Uri>.
|
This example demonstrates how to decode a Windows Media Photo image using a <xref:System.Windows.Media.Imaging.WmpBitmapDecoder> from a <xref:System.Uri>.
|
||||||
|
|
||||||
[!code-cpp[WdpBitmapDecoderEncoder#1](~/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/WDPEncoderDecoder.cpp#1)]
|
[!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-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)]
|
[!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 <xref:System.Windows.Media.Imaging.BitmapSource> into a Windows Media Photo image using a <xref:System.Windows.Media.Imaging.WmpBitmapEncoder>.
|
This example demonstrates how to encode a <xref:System.Windows.Media.Imaging.BitmapSource> into a Windows Media Photo image using a <xref:System.Windows.Media.Imaging.WmpBitmapEncoder>.
|
||||||
|
|
||||||
[!code-cpp[WdpBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/WDPEncoderDecoder.cpp#4)]
|
[!code-cpp[WdpBitmapDecoderEncoder#4](~/samples/snippets/cpp/VS_Snippets_Wpf/WdpBitmapDecoderEncoder/CPP/WDPEncoderDecoder.cpp#4)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Load an Image as a Thumbnail"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -13,12 +15,12 @@ ms.assetid: 02e055a0-54df-499a-b8b6-ab6ff7535cff
|
|||||||
# How to: Load an Image as a Thumbnail
|
# How to: Load an Image as a Thumbnail
|
||||||
The following examples show how to load an <xref:System.Windows.Controls.Image> as a thumbnail to conserve application memory.
|
The following examples show how to load an <xref:System.Windows.Controls.Image> as a thumbnail to conserve application memory.
|
||||||
|
|
||||||
## Example
|
## Set the DecodePixelWidth property in XAML
|
||||||
The following example sets the <xref:System.Windows.Media.Imaging.BitmapImage.DecodePixelWidth%2A> property of a <xref:System.Windows.Media.Imaging.BitmapImage> in [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] to reduce the memory required to load the image.
|
The following example sets the <xref:System.Windows.Media.Imaging.BitmapImage.DecodePixelWidth%2A> property of a <xref:System.Windows.Media.Imaging.BitmapImage> 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)]
|
[!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 <xref:System.Windows.Media.Imaging.BitmapImage.DecodePixelWidth%2A> property of a <xref:System.Windows.Media.Imaging.BitmapImage> in code to reduce the memory required to load the image.
|
The following example sets the <xref:System.Windows.Media.Imaging.BitmapImage.DecodePixelWidth%2A> property of a <xref:System.Windows.Media.Imaging.BitmapImage> 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)]
|
[!code-csharp[ImageElementExample_snip#ImageSimpleExampleInlineCode1](~/samples/snippets/csharp/VS_Snippets_Wpf/ImageElementExample_snip/CSharp/ImageSimpleExample.xaml.cs#imagesimpleexampleinlinecode1)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Paint an Area with a Video"
|
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.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -13,14 +15,14 @@ ms.assetid: 04dd6600-4a6e-4b43-a93e-21cce7dfbcb8
|
|||||||
# How to: Paint an Area with a Video
|
# 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 <xref:System.Windows.Controls.MediaElement> together with a <xref:System.Windows.Media.VisualBrush>. Use the <xref:System.Windows.Controls.MediaElement> to load and play the media, and then use it to set the <xref:System.Windows.Media.VisualBrush.Visual%2A> property of the <xref:System.Windows.Media.VisualBrush>. You can then use the <xref:System.Windows.Media.VisualBrush> to paint an area with the loaded media.
|
This example shows how to paint an area with media. One way to paint an area with media is to use a <xref:System.Windows.Controls.MediaElement> together with a <xref:System.Windows.Media.VisualBrush>. Use the <xref:System.Windows.Controls.MediaElement> to load and play the media, and then use it to set the <xref:System.Windows.Media.VisualBrush.Visual%2A> property of the <xref:System.Windows.Media.VisualBrush>. You can then use the <xref:System.Windows.Media.VisualBrush> to paint an area with the loaded media.
|
||||||
|
|
||||||
## Example
|
## Use a MediaElement with a VisualBrush
|
||||||
The following example uses a <xref:System.Windows.Controls.MediaElement> and a <xref:System.Windows.Media.VisualBrush> to paint the <xref:System.Windows.Controls.TextBlock.Foreground%2A> of a <xref:System.Windows.Controls.TextBlock> control with video. This example sets the <xref:System.Windows.Controls.MediaElement.IsMuted%2A> property of the <xref:System.Windows.Controls.MediaElement> to `true` so that it produces no sound.
|
The following example uses a <xref:System.Windows.Controls.MediaElement> and a <xref:System.Windows.Media.VisualBrush> to paint the <xref:System.Windows.Controls.TextBlock.Foreground%2A> of a <xref:System.Windows.Controls.TextBlock> control with video. This example sets the <xref:System.Windows.Controls.MediaElement.IsMuted%2A> property of the <xref:System.Windows.Controls.MediaElement> 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-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-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)]
|
[!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 <xref:System.Windows.Media.VisualBrush> inherits from the <xref:System.Windows.Media.TileBrush> class, it provides several tiling modes. By setting the <xref:System.Windows.Media.TileBrush.TileMode%2A> property of a <xref:System.Windows.Media.VisualBrush> to <xref:System.Windows.Media.TileMode.Tile> and by setting its <xref:System.Windows.Media.TileBrush.Viewport%2A> property to a value smaller than the area that you are painting, you can create a tiled pattern.
|
Because <xref:System.Windows.Media.VisualBrush> inherits from the <xref:System.Windows.Media.TileBrush> class, it provides several tiling modes. By setting the <xref:System.Windows.Media.TileBrush.TileMode%2A> property of a <xref:System.Windows.Media.VisualBrush> to <xref:System.Windows.Media.TileMode.Tile> and by setting its <xref:System.Windows.Media.TileBrush.Viewport%2A> 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 <xref:System.Windows.Media.VisualBrush> generates a pattern from the video.
|
The following example is identical to the previous example, except that the <xref:System.Windows.Media.VisualBrush> generates a pattern from the video.
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ The `ButtonCreatedByCode_Click` event handler obtains the following information
|
|||||||
- The <xref:System.Windows.RoutedEventArgs.Source?displayProperty=nameWithType> object, which is the element that originally raised the event. In this example, the `Source` is always `ButtonCreatedByCode`.
|
- The <xref:System.Windows.RoutedEventArgs.Source?displayProperty=nameWithType> object, which is the element that originally raised the event. In this example, the `Source` is always `ButtonCreatedByCode`.
|
||||||
|
|
||||||
> [!NOTE]
|
> [!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).
|
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).
|
||||||
|
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
<Application x:Class="Application"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:CodeSampleVb"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
Class Application
|
||||||
|
|
||||||
|
' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
|
||||||
|
' can be handled in this file.
|
||||||
|
|
||||||
|
End Class
|
||||||
+11
@@ -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)
|
||||||
|
<Assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)>
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<RootNamespace>CodeSampleVb</RootNamespace>
|
||||||
|
<NeutralLanguage>en-us</NeutralLanguage>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Import Include="System.Windows" />
|
||||||
|
<Import Include="System.Windows.Controls" />
|
||||||
|
<Import Include="System.Windows.Data" />
|
||||||
|
<Import Include="System.Windows.Documents" />
|
||||||
|
<Import Include="System.Windows.Input" />
|
||||||
|
<Import Include="System.Windows.Media" />
|
||||||
|
<Import Include="System.Windows.Media.Imaging" />
|
||||||
|
<Import Include="System.Windows.Navigation" />
|
||||||
|
<Import Include="System.Windows.Shapes" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
<Window x:Class="CodeSampleVb.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="Visual Basic and WPF event handling" Height="100" Width="400">
|
||||||
|
|
||||||
|
<!--<ButtonCreatedByXaml>-->
|
||||||
|
<StackPanel Name="StackPanel1">
|
||||||
|
<Button
|
||||||
|
Name="XamlButton"
|
||||||
|
Content="Create a new button with an event handler"
|
||||||
|
Background="LightGray">
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
<!--</ButtonCreatedByXaml>-->
|
||||||
|
</Window>
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
Imports System.Windows.Controls.Primitives
|
||||||
|
|
||||||
|
Namespace CodeSampleVb
|
||||||
|
|
||||||
|
' <summary>
|
||||||
|
' Interaction logic for MainWindow.xaml.
|
||||||
|
' </summary>
|
||||||
|
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
|
||||||
|
|
||||||
|
'<Window_Loaded>
|
||||||
|
' 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
|
||||||
|
'</Window_Loaded>
|
||||||
|
|
||||||
|
'<CodeButton_Click>
|
||||||
|
' 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
|
||||||
|
'</CodeButton_Click>
|
||||||
|
|
||||||
|
'<XamlButton_Click>
|
||||||
|
' 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
|
||||||
|
'</XamlButton_Click>
|
||||||
|
|
||||||
|
End Class
|
||||||
|
|
||||||
|
End Namespace
|
||||||
@@ -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"
|
||||||
|
---
|
||||||
|
<!-- The acrolinx score was 100 on 02/25/2021-->
|
||||||
|
|
||||||
|
# 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 <procedure name> Handles <object name>.<event name>`. That syntax designates a procedure as the event handler that will run when an event specified by `<event name>` is raised on an object specified by `<object name>`. 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 `<object name>.<event name>` 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 `<object name>.<event name>` requires the XAML element that represents the object to have a <xref:System.Windows.FrameworkContentElement.Name%2A> 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 <xref:System.Windows.UIElement.AddHandler%2A> 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 <xref:System.Windows.Controls.Primitives.ButtonBase.Click> event handler to a button whose base class <xref:System.Windows.Forms.ButtonBase> 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 <xref:System.Windows.UIElement.AddHandler%2A> 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 <xref:System.Windows.RoutedEventArgs.Handled> events. To enable your event handler to be invoked for `Handled` events, attach the event handler using the <xref:System.Windows.UIElement.AddHandler%28System.Windows.RoutedEvent%2CSystem.Delegate%2CSystem.Boolean%29> method and set its `handledEventsToo` parameter to `true`.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- <xref:System.Windows.UIElement.AddHandler%2A>
|
||||||
|
- [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)
|
||||||
@@ -80,6 +80,8 @@ items:
|
|||||||
items:
|
items:
|
||||||
- name: Events
|
- name: Events
|
||||||
items:
|
items:
|
||||||
|
- name: Visual Basic and WPF event handling
|
||||||
|
href: events/visual-basic-and-wpf-event-handling.md
|
||||||
- name: Common tasks
|
- name: Common tasks
|
||||||
items:
|
items:
|
||||||
- name: Add an event handler using code
|
- name: Add an event handler using code
|
||||||
|
|||||||
@@ -338,6 +338,11 @@
|
|||||||
"SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-create-a-custom-routed-event?view=netframeworkdesktop-4.8",
|
"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"
|
"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
|
// Systems - Properties
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user