mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-04 09:06:04 +02:00
Merge pull request #1322 from dotnet/publish-6249
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
title: "StaticResource Markup Extension"
|
title: "StaticResource Markup Extension"
|
||||||
description: Provides a value for any XAML property attribute by looking up a reference to an already defined resource.
|
description: Provides a value for any XAML property attribute by looking up a reference to an already defined resource.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
f1_keywords:
|
f1_keywords:
|
||||||
- "StaticResource"
|
- "StaticResource"
|
||||||
- "StaticResourceExtension"
|
- "StaticResourceExtension"
|
||||||
@@ -31,8 +32,8 @@ Provides a value for any [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla
|
|||||||
|
|
||||||
## XAML Values
|
## XAML Values
|
||||||
|
|
||||||
|||
|
| Value | Description |
|
||||||
|-|-|
|
|-------|-------------|
|
||||||
|`key`|The key for the requested resource. This key was initially assigned by the [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive) if a resource was created in markup, or was provided as the `key` parameter when calling <xref:System.Windows.ResourceDictionary.Add%2A?displayProperty=nameWithType> if the resource was created in code.|
|
|`key`|The key for the requested resource. This key was initially assigned by the [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive) if a resource was created in markup, or was provided as the `key` parameter when calling <xref:System.Windows.ResourceDictionary.Add%2A?displayProperty=nameWithType> if the resource was created in code.|
|
||||||
|
|
||||||
## Remarks
|
## Remarks
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "TemplateBinding Markup Extension"
|
title: "TemplateBinding Markup Extension"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn about the TemplateBinding Markup Extension.
|
||||||
f1_keywords:
|
f1_keywords:
|
||||||
- "TemplateBinding"
|
- "TemplateBinding"
|
||||||
- "TemplateBindingExtension"
|
- "TemplateBindingExtension"
|
||||||
@@ -26,8 +28,8 @@ Links the value of a property in a control template to be the value of another p
|
|||||||
|
|
||||||
## XAML Values
|
## XAML Values
|
||||||
|
|
||||||
|||
|
| Value | Description |
|
||||||
|-|-|
|
|-------|-------------|
|
||||||
|`propertyName`|<xref:System.Windows.DependencyProperty.Name%2A?displayProperty=nameWithType> of the property being set in the setter syntax.|
|
|`propertyName`|<xref:System.Windows.DependencyProperty.Name%2A?displayProperty=nameWithType> of the property being set in the setter syntax.|
|
||||||
|`sourceProperty`|Another dependency property that exists on the type being templated, specified by its <xref:System.Windows.DependencyProperty.Name%2A?displayProperty=nameWithType>.<br /><br /> - or -<br /><br /> A "dotted-down" property name that is defined by a different type than the target type being templated. This is actually a <xref:System.Windows.PropertyPath>. See [PropertyPath XAML Syntax](propertypath-xaml-syntax.md).|
|
|`sourceProperty`|Another dependency property that exists on the type being templated, specified by its <xref:System.Windows.DependencyProperty.Name%2A?displayProperty=nameWithType>.<br /><br /> - or -<br /><br /> A "dotted-down" property name that is defined by a different type than the target type being templated. This is actually a <xref:System.Windows.PropertyPath>. See [PropertyPath XAML Syntax](propertypath-xaml-syntax.md).|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "ThemeDictionary Markup Extension"
|
title: "ThemeDictionary Markup Extension"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn about the ThemeDictionary Markup Extension.
|
||||||
f1_keywords:
|
f1_keywords:
|
||||||
- "ThemeDictionaryExtension"
|
- "ThemeDictionaryExtension"
|
||||||
- "ThemeDictionary"
|
- "ThemeDictionary"
|
||||||
@@ -30,8 +32,8 @@ Provides a way for custom control authors or applications that integrate third-p
|
|||||||
|
|
||||||
## XAML Values
|
## XAML Values
|
||||||
|
|
||||||
|||
|
| Value | Description |
|
||||||
|-|-|
|
|-------|-------------|
|
||||||
|`assemblyUri`|The uniform resource identifier (URI) of the assembly that contains theme information. Typically, this is a pack URI that references an assembly in the larger package. Assembly resources and pack URIs simplify deployment issues. For more information see [Pack URIs in WPF](../app-development/pack-uris-in-wpf.md).|
|
|`assemblyUri`|The uniform resource identifier (URI) of the assembly that contains theme information. Typically, this is a pack URI that references an assembly in the larger package. Assembly resources and pack URIs simplify deployment issues. For more information see [Pack URIs in WPF](../app-development/pack-uris-in-wpf.md).|
|
||||||
|
|
||||||
## Remarks
|
## Remarks
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "Typography"
|
title: "Typography in WPF"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn about the typography in WPF.
|
||||||
helpviewer_keywords:
|
helpviewer_keywords:
|
||||||
- "typography [WPF], about typography"
|
- "typography [WPF], about typography"
|
||||||
ms.assetid: 06cbf17b-6eff-4fe5-949d-2dd533e4e1f4
|
ms.assetid: 06cbf17b-6eff-4fe5-949d-2dd533e4e1f4
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "Typography"
|
title: "Typography"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn about the typography.
|
||||||
f1_keywords:
|
f1_keywords:
|
||||||
- "AutoGeneratedOrientationPage"
|
- "AutoGeneratedOrientationPage"
|
||||||
helpviewer_keywords:
|
helpviewer_keywords:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
title: "XAML Syntax In Detail"
|
title: "XAML Syntax In Detail"
|
||||||
description: Learn about terms that are used to describe the elements of XAML syntax for Windows Presentation Foundation and other frameworks that use XAML.
|
description: Learn about terms that are used to describe the elements of XAML syntax for Windows Presentation Foundation and other frameworks that use XAML.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
ms.topic: overview
|
ms.topic: overview
|
||||||
helpviewer_keywords:
|
helpviewer_keywords:
|
||||||
- "XML [WPF], namespaces"
|
- "XML [WPF], namespaces"
|
||||||
@@ -273,8 +274,8 @@ This topic defines the terms that are used to describe the elements of XAML synt
|
|||||||
## Anatomy of a XAML Root Element
|
## Anatomy of a XAML Root Element
|
||||||
The following table shows a typical XAML root element broken down, showing the specific attributes of a root element:
|
The following table shows a typical XAML root element broken down, showing the specific attributes of a root element:
|
||||||
|
|
||||||
|||
|
| Attribute | Description |
|
||||||
|-|-|
|
|-----------|-------------|
|
||||||
|`<Page`|Opening object element of the root element|
|
|`<Page`|Opening object element of the root element|
|
||||||
|`xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"`|The default (WPF) XAML namespace|
|
|`xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"`|The default (WPF) XAML namespace|
|
||||||
|`xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"`|The XAML language XAML namespace|
|
|`xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"`|The XAML language XAML namespace|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
title: "Adorners Overview"
|
title: "Adorners Overview"
|
||||||
description: Learn about Windows Presentation Foundation Adorners, a special type of FrameworkElement that provides cues to a user, such as functional handles for elements.
|
description: Learn about Windows Presentation Foundation Adorners, a special type of FrameworkElement that provides cues to a user, such as functional handles for elements.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
ms.topic: overview
|
ms.topic: overview
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
@@ -27,8 +28,8 @@ Common applications for adorners include:
|
|||||||
|
|
||||||
[!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] provides a basic framework for adorning visual elements. The following table lists the primary types used when adorning objects, and their purpose. Several usage examples follow:
|
[!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] provides a basic framework for adorning visual elements. The following table lists the primary types used when adorning objects, and their purpose. Several usage examples follow:
|
||||||
|
|
||||||
|||
|
| Class | Description |
|
||||||
|-|-|
|
|------|-------------|
|
||||||
|<xref:System.Windows.Documents.Adorner>|An abstract base class from which all concrete adorner implementations inherit.|
|
|<xref:System.Windows.Documents.Adorner>|An abstract base class from which all concrete adorner implementations inherit.|
|
||||||
|<xref:System.Windows.Documents.AdornerLayer>|A class representing a rendering layer for the adorner(s) of one or more adorned elements.|
|
|<xref:System.Windows.Documents.AdornerLayer>|A class representing a rendering layer for the adorner(s) of one or more adorned elements.|
|
||||||
|<xref:System.Windows.Documents.AdornerDecorator>|A class that enables an adorner layer to be associated with a collection of elements.|
|
|<xref:System.Windows.Documents.AdornerDecorator>|A class that enables an adorner layer to be associated with a collection of elements.|
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "Change Selection in a RichTextBox Programmatically"
|
title: "Change Selection in a RichTextBox Programmatically"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn how to change selection in a RichTextBox programmatically.
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -12,12 +14,12 @@ ms.assetid: f1213205-1ad7-4cd2-b115-460173cc5aa3
|
|||||||
# Change Selection in a RichTextBox Programmatically
|
# Change Selection in a RichTextBox Programmatically
|
||||||
This example shows how to programmatically change the current selection in a <xref:System.Windows.Controls.RichTextBox>. This selection is the same as if the user had selected the content by using the user interface.
|
This example shows how to programmatically change the current selection in a <xref:System.Windows.Controls.RichTextBox>. This selection is the same as if the user had selected the content by using the user interface.
|
||||||
|
|
||||||
## Example
|
## Code example for a RichTextBox control
|
||||||
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] code describes a named <xref:System.Windows.Controls.RichTextBox> control with simple content.
|
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] code describes a named <xref:System.Windows.Controls.RichTextBox> control with simple content.
|
||||||
|
|
||||||
[!code-xaml[RichTextBoxMiscSnippets_snip#ChangeSelectionProgrammaticalyExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/ChangeSelectionProgrammaticaly.xaml#changeselectionprogrammaticalyexamplewholepage)]
|
[!code-xaml[RichTextBoxMiscSnippets_snip#ChangeSelectionProgrammaticalyExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/ChangeSelectionProgrammaticaly.xaml#changeselectionprogrammaticalyexamplewholepage)]
|
||||||
|
|
||||||
## Example
|
## Code example to select text from a RichTextBox
|
||||||
The following code programmatically selects some arbitrary text when the user clicks inside the <xref:System.Windows.Controls.RichTextBox>.
|
The following code programmatically selects some arbitrary text when the user clicks inside the <xref:System.Windows.Controls.RichTextBox>.
|
||||||
|
|
||||||
[!code-csharp[RichTextBoxMiscSnippets_snip#ChangeSelectionProgrammaticalyCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/ChangeSelectionProgrammaticaly.xaml.cs#changeselectionprogrammaticalycodeexamplewholepage)]
|
[!code-csharp[RichTextBoxMiscSnippets_snip#ChangeSelectionProgrammaticalyCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/ChangeSelectionProgrammaticaly.xaml.cs#changeselectionprogrammaticalycodeexamplewholepage)]
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "GridView Column Header Styles and Templates Overview"
|
title: "GridView Column Header Styles and Templates Overview"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn about the GridView column header styles and templates.
|
||||||
helpviewer_keywords:
|
helpviewer_keywords:
|
||||||
- "column headers [WPF], customizing"
|
- "column headers [WPF], customizing"
|
||||||
- "ListView controls [WPF], GridView column header styles"
|
- "ListView controls [WPF], GridView column header styles"
|
||||||
@@ -19,9 +21,8 @@ This overview discusses the order of precedence for properties that you use to c
|
|||||||
|
|
||||||
**Related properties for column headers in a GridView**
|
**Related properties for column headers in a GridView**
|
||||||
|
|
||||||
|||||
|
| | <xref:System.Windows.Controls.GridView> | <xref:System.Windows.Controls.GridViewColumn> |<xref:System.Windows.Controls.GridViewColumnHeader>|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|**Classes**|<xref:System.Windows.Controls.GridView>|<xref:System.Windows.Controls.GridViewColumn>|<xref:System.Windows.Controls.GridViewColumnHeader>|
|
|
||||||
|**Context Menu Properties**|<xref:System.Windows.Controls.GridView.ColumnHeaderContextMenu%2A>|Not applicable|<xref:System.Windows.FrameworkElement.ContextMenu%2A>|
|
|**Context Menu Properties**|<xref:System.Windows.Controls.GridView.ColumnHeaderContextMenu%2A>|Not applicable|<xref:System.Windows.FrameworkElement.ContextMenu%2A>|
|
||||||
|**ToolTip**<br /><br /> **Properties**|<xref:System.Windows.Controls.GridView.ColumnHeaderToolTip%2A>|Not applicable|<xref:System.Windows.FrameworkElement.ToolTip%2A>|
|
|**ToolTip**<br /><br /> **Properties**|<xref:System.Windows.Controls.GridView.ColumnHeaderToolTip%2A>|Not applicable|<xref:System.Windows.FrameworkElement.ToolTip%2A>|
|
||||||
|**Header Template**<br /><br /> **Properties**|<xref:System.Windows.Controls.GridView.ColumnHeaderTemplate%2A> <sup>1</sup>/<br /><br /> <xref:System.Windows.Controls.GridView.ColumnHeaderTemplateSelector%2A>|<xref:System.Windows.Controls.GridViewColumn.HeaderTemplate%2A> <sup>1</sup>/<br /><br /> <xref:System.Windows.Controls.GridViewColumn.HeaderTemplateSelector%2A>|<xref:System.Windows.Controls.ContentControl.ContentTemplate%2A> <sup>1</sup>/<br /><br /> <xref:System.Windows.Controls.ContentControl.ContentTemplateSelector%2A>|
|
|**Header Template**<br /><br /> **Properties**|<xref:System.Windows.Controls.GridView.ColumnHeaderTemplate%2A> <sup>1</sup>/<br /><br /> <xref:System.Windows.Controls.GridView.ColumnHeaderTemplateSelector%2A>|<xref:System.Windows.Controls.GridViewColumn.HeaderTemplate%2A> <sup>1</sup>/<br /><br /> <xref:System.Windows.Controls.GridViewColumn.HeaderTemplateSelector%2A>|<xref:System.Windows.Controls.ContentControl.ContentTemplate%2A> <sup>1</sup>/<br /><br /> <xref:System.Windows.Controls.ContentControl.ContentTemplateSelector%2A>|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ description: Learn how to create and reference a control template in Windows Pre
|
|||||||
author: adegeo
|
author: adegeo
|
||||||
ms.author: adegeo
|
ms.author: adegeo
|
||||||
ms.date: 12/03/2020
|
ms.date: 12/03/2020
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
no-loc: ["<Window>", "<ControlTemplate>", "<Ellipse>", "<ContentPresenter>", "<Trigger>", "<Setter>", "<PropertyTrigger>", "<Grid>", "<VisualStateManager.VisualStateGroups>", "<VisualStateGroup>", "<VisualState>", "<Storyboard>", "SizeToContent", "MinWidth", "TargetType", "Title"]
|
no-loc: ["<Window>", "<ControlTemplate>", "<Ellipse>", "<ContentPresenter>", "<Trigger>", "<Setter>", "<PropertyTrigger>", "<Grid>", "<VisualStateManager.VisualStateGroups>", "<VisualStateGroup>", "<VisualState>", "<Storyboard>", "SizeToContent", "MinWidth", "TargetType", "Title"]
|
||||||
ms.topic: how-to
|
ms.topic: how-to
|
||||||
helpviewer_keywords:
|
helpviewer_keywords:
|
||||||
@@ -35,11 +36,11 @@ On the other hand, if you need a control with new functionality, different prope
|
|||||||
|
|
||||||
Create a new WPF application and in *MainWindow.xaml* (or another window of your choice) set the following properties on the **\<Window>** element:
|
Create a new WPF application and in *MainWindow.xaml* (or another window of your choice) set the following properties on the **\<Window>** element:
|
||||||
|
|
||||||
| | |
|
| Property | Value |
|
||||||
| --- | --- |
|
|----------|-------|
|
||||||
| **Title** | `Template Intro Sample` |
|
| **Title** | `Template Intro Sample` |
|
||||||
| **SizeToContent** | `WidthAndHeight` |
|
| **SizeToContent** | `WidthAndHeight` |
|
||||||
| **MinWidth** | `250` |
|
| **MinWidth** | `250` |
|
||||||
|
|
||||||
Set the content of the **\<Window>** element to the following XAML:
|
Set the content of the **\<Window>** element to the following XAML:
|
||||||
|
|
||||||
@@ -63,10 +64,10 @@ To start with, add a `Window.Resources` element to your *MainWindow.xaml* file:
|
|||||||
|
|
||||||
Create a new **\<ControlTemplate>** with the following properties set:
|
Create a new **\<ControlTemplate>** with the following properties set:
|
||||||
|
|
||||||
| | |
|
| Property | Value |
|
||||||
| --- | --- |
|
| ----- | ---------- |
|
||||||
| **x:Key** | `roundbutton` |
|
| **x:Key** | `roundbutton` |
|
||||||
| **TargetType** | `Button` |
|
| **TargetType** | `Button` |
|
||||||
|
|
||||||
This control template will be simple:
|
This control template will be simple:
|
||||||
|
|
||||||
|
|||||||
+4
-6
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Customize the Thumb Size on a ScrollBar"
|
title: "How to: Customize the Thumb Size on a ScrollBar"
|
||||||
|
description: Learn how to customize the Thumb Size on a ScrollBar.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
helpviewer_keywords:
|
helpviewer_keywords:
|
||||||
- "ScrollBar control [WPF]"
|
- "ScrollBar control [WPF]"
|
||||||
- "customizing thumb size [WPF]"
|
- "customizing thumb size [WPF]"
|
||||||
@@ -10,18 +12,14 @@ ms.assetid: fa32b866-5ca1-4e73-85e7-2ac64b80d194
|
|||||||
# How to: Customize the Thumb Size on a ScrollBar
|
# How to: Customize the Thumb Size on a ScrollBar
|
||||||
This topic explains how to set the <xref:System.Windows.Controls.Primitives.Thumb> of a <xref:System.Windows.Controls.Primitives.ScrollBar> to a fixed size and how to specify a minimum size for the <xref:System.Windows.Controls.Primitives.Thumb> of a <xref:System.Windows.Controls.Primitives.ScrollBar>.
|
This topic explains how to set the <xref:System.Windows.Controls.Primitives.Thumb> of a <xref:System.Windows.Controls.Primitives.ScrollBar> to a fixed size and how to specify a minimum size for the <xref:System.Windows.Controls.Primitives.Thumb> of a <xref:System.Windows.Controls.Primitives.ScrollBar>.
|
||||||
|
|
||||||
## Example
|
## Create a ScrollBar with a fixed Thumb size
|
||||||
|
|
||||||
## Description
|
|
||||||
The following example creates a <xref:System.Windows.Controls.Primitives.ScrollBar> that has a <xref:System.Windows.Controls.Primitives.Thumb> with a fixed size. The example sets the <xref:System.Windows.Controls.Primitives.Track.ViewportSize%2A> property of the <xref:System.Windows.Controls.Primitives.Thumb> to <xref:System.Double.NaN> and sets the height of the <xref:System.Windows.Controls.Primitives.Thumb>. To create a horizontal <xref:System.Windows.Controls.Primitives.ScrollBar> with a <xref:System.Windows.Controls.Primitives.Thumb> that has a fixed width, set the width of the <xref:System.Windows.Controls.Primitives.Thumb>.
|
The following example creates a <xref:System.Windows.Controls.Primitives.ScrollBar> that has a <xref:System.Windows.Controls.Primitives.Thumb> with a fixed size. The example sets the <xref:System.Windows.Controls.Primitives.Track.ViewportSize%2A> property of the <xref:System.Windows.Controls.Primitives.Thumb> to <xref:System.Double.NaN> and sets the height of the <xref:System.Windows.Controls.Primitives.Thumb>. To create a horizontal <xref:System.Windows.Controls.Primitives.ScrollBar> with a <xref:System.Windows.Controls.Primitives.Thumb> that has a fixed width, set the width of the <xref:System.Windows.Controls.Primitives.Thumb>.
|
||||||
|
|
||||||
## Code
|
|
||||||
[!code-xaml[ScrollBarCustomThumbSize#1](~/samples/snippets/csharp/VS_Snippets_Wpf/ScrollBarCustomThumbSize/CS/Window1.xaml#1)]
|
[!code-xaml[ScrollBarCustomThumbSize#1](~/samples/snippets/csharp/VS_Snippets_Wpf/ScrollBarCustomThumbSize/CS/Window1.xaml#1)]
|
||||||
|
|
||||||
## Description
|
## Create a ScrollBar with a minimum Thumb size
|
||||||
The following example creates a <xref:System.Windows.Controls.Primitives.ScrollBar> that has a <xref:System.Windows.Controls.Primitives.Thumb> with a minimum size. The example sets the value of <xref:System.Windows.SystemParameters.VerticalScrollBarButtonHeightKey%2A>. To create a horizontal <xref:System.Windows.Controls.Primitives.ScrollBar> with a <xref:System.Windows.Controls.Primitives.Thumb> that has a minimum width, set the <xref:System.Windows.SystemParameters.HorizontalScrollBarButtonWidthKey%2A>.
|
The following example creates a <xref:System.Windows.Controls.Primitives.ScrollBar> that has a <xref:System.Windows.Controls.Primitives.Thumb> with a minimum size. The example sets the value of <xref:System.Windows.SystemParameters.VerticalScrollBarButtonHeightKey%2A>. To create a horizontal <xref:System.Windows.Controls.Primitives.ScrollBar> with a <xref:System.Windows.Controls.Primitives.Thumb> that has a minimum width, set the <xref:System.Windows.SystemParameters.HorizontalScrollBarButtonWidthKey%2A>.
|
||||||
|
|
||||||
## Code
|
|
||||||
[!code-xaml[ScrollBarCustomThumbSize#2](~/samples/snippets/csharp/VS_Snippets_Wpf/ScrollBarCustomThumbSize/CS/Window1.xaml#2)]
|
[!code-xaml[ScrollBarCustomThumbSize#2](~/samples/snippets/csharp/VS_Snippets_Wpf/ScrollBarCustomThumbSize/CS/Window1.xaml#2)]
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|||||||
+3
-2
@@ -2,6 +2,7 @@
|
|||||||
title: "How to: Detect When Text in a TextBox Has Changed"
|
title: "How to: Detect When Text in a TextBox Has Changed"
|
||||||
description: Learn how to use the TextChanged event to run a method whenever the text in a TextBox control changes in a Windows Presentation Foundation application.
|
description: Learn how to use the TextChanged event to run a method whenever the text in a TextBox control changes in a Windows Presentation Foundation application.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -22,13 +23,13 @@ The event handler is called whenever the contents of the <xref:System.Windows.Co
|
|||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> This event fires when the <xref:System.Windows.Controls.TextBox> control is created and initially populated with text.
|
> This event fires when the <xref:System.Windows.Controls.TextBox> control is created and initially populated with text.
|
||||||
|
|
||||||
## Example
|
## Define TextBox control
|
||||||
|
|
||||||
In the [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] that defines your <xref:System.Windows.Controls.TextBox> control, specify the <xref:System.Windows.Controls.Primitives.TextBoxBase.TextChanged> attribute with a value that matches the event handler method name.
|
In the [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] that defines your <xref:System.Windows.Controls.TextBox> control, specify the <xref:System.Windows.Controls.Primitives.TextBoxBase.TextChanged> attribute with a value that matches the event handler method name.
|
||||||
|
|
||||||
[!code-xaml[TextBox_MiscCode#_TextChangedXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_textchangedxaml)]
|
[!code-xaml[TextBox_MiscCode#_TextChangedXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_textchangedxaml)]
|
||||||
|
|
||||||
## Example
|
## Monitor the TextBox control changes
|
||||||
|
|
||||||
In the code-behind class for the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] that contains the <xref:System.Windows.Controls.TextBox> control that you want to monitor for changes, insert a method to call whenever the <xref:System.Windows.Controls.Primitives.TextBoxBase.TextChanged> event fires. This method must have a signature that matches what is expected by the <xref:System.Windows.Controls.TextChangedEventHandler> delegate.
|
In the code-behind class for the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] that contains the <xref:System.Windows.Controls.TextBox> control that you want to monitor for changes, insert a method to call whenever the <xref:System.Windows.Controls.Primitives.TextBoxBase.TextChanged> event fires. This method must have a signature that matches what is expected by the <xref:System.Windows.Controls.TextChangedEventHandler> delegate.
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Extract the Text Content from a RichTextBox"
|
title: "How to: Extract the Text Content from a RichTextBox"
|
||||||
|
description: Learn how to extract the Text Content from a RichTextBox.
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -14,12 +16,12 @@ ms.assetid: f13c093f-1a05-45b3-ac8f-c9ea5e4a11c5
|
|||||||
# How to: Extract the Text Content from a RichTextBox
|
# How to: Extract the Text Content from a RichTextBox
|
||||||
This example shows how to extract the contents of a <xref:System.Windows.Controls.RichTextBox> as plain text.
|
This example shows how to extract the contents of a <xref:System.Windows.Controls.RichTextBox> as plain text.
|
||||||
|
|
||||||
## Example
|
## Describe a RichTextBox control
|
||||||
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] code describes a named <xref:System.Windows.Controls.RichTextBox> control with simple content.
|
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] code describes a named <xref:System.Windows.Controls.RichTextBox> control with simple content.
|
||||||
|
|
||||||
[!code-xaml[RichTextBoxSnippets#_RTB_XAML](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxSnippets/CSharp/Window1.xaml#_rtb_xaml)]
|
[!code-xaml[RichTextBoxSnippets#_RTB_XAML](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxSnippets/CSharp/Window1.xaml#_rtb_xaml)]
|
||||||
|
|
||||||
## Example
|
## Code example with RichTextBox as an argument
|
||||||
The following code implements a method that takes a <xref:System.Windows.Controls.RichTextBox> as an argument, and returns a string representing the plain text contents of the <xref:System.Windows.Controls.RichTextBox>.
|
The following code implements a method that takes a <xref:System.Windows.Controls.RichTextBox> as an argument, and returns a string representing the plain text contents of the <xref:System.Windows.Controls.RichTextBox>.
|
||||||
|
|
||||||
The method creates a new <xref:System.Windows.Documents.TextRange> from the contents of the <xref:System.Windows.Controls.RichTextBox>, using the <xref:System.Windows.Documents.FlowDocument.ContentStart%2A> and <xref:System.Windows.Documents.FlowDocument.ContentEnd%2A> to indicate the range of the contents to extract. <xref:System.Windows.Documents.FlowDocument.ContentStart%2A> and <xref:System.Windows.Documents.FlowDocument.ContentEnd%2A> properties each return a <xref:System.Windows.Documents.TextPointer>, and are accessible on the underlying FlowDocument that represents the contents of the <xref:System.Windows.Controls.RichTextBox>. <xref:System.Windows.Documents.TextRange> provides a Text property, which returns the plain text portions of the <xref:System.Windows.Documents.TextRange> as a string.
|
The method creates a new <xref:System.Windows.Documents.TextRange> from the contents of the <xref:System.Windows.Controls.RichTextBox>, using the <xref:System.Windows.Documents.FlowDocument.ContentStart%2A> and <xref:System.Windows.Documents.FlowDocument.ContentEnd%2A> to indicate the range of the contents to extract. <xref:System.Windows.Documents.FlowDocument.ContentStart%2A> and <xref:System.Windows.Documents.FlowDocument.ContentEnd%2A> properties each return a <xref:System.Windows.Documents.TextPointer>, and are accessible on the underlying FlowDocument that represents the contents of the <xref:System.Windows.Controls.RichTextBox>. <xref:System.Windows.Documents.TextRange> provides a Text property, which returns the plain text portions of the <xref:System.Windows.Documents.TextRange> as a string.
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Position a Custom Context Menu in a RichTextBox"
|
title: "How to: Position a Custom Context Menu in a RichTextBox"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn how to position a Custom Context Menu in a RichTextBox.
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -16,13 +18,13 @@ This example shows how to position a custom context menu for a <xref:System.Wind
|
|||||||
|
|
||||||
When you implement a custom context menu for a **RichTextBox**, you are responsible for handling the placement of the context menu. By default, a custom context menu is opened at the center of the **RichTextBox**.
|
When you implement a custom context menu for a **RichTextBox**, you are responsible for handling the placement of the context menu. By default, a custom context menu is opened at the center of the **RichTextBox**.
|
||||||
|
|
||||||
## Example
|
## Add a listener for the ContextMenuOpening event
|
||||||
To override the default placement behavior, add a listener for the <xref:System.Windows.FrameworkContentElement.ContextMenuOpening> event. The following example shows how to do this programmatically.
|
To override the default placement behavior, add a listener for the <xref:System.Windows.FrameworkContentElement.ContextMenuOpening> event. The following example shows how to do this programmatically.
|
||||||
|
|
||||||
[!code-csharp[RichTextBox_ContextMenu#_AddListener](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBox_ContextMenu/CSharp/app.xaml.cs#_addlistener)]
|
[!code-csharp[RichTextBox_ContextMenu#_AddListener](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBox_ContextMenu/CSharp/app.xaml.cs#_addlistener)]
|
||||||
[!code-vb[RichTextBox_ContextMenu#_AddListener](~/samples/snippets/visualbasic/VS_Snippets_Wpf/RichTextBox_ContextMenu/VisualBasic/app.xaml.vb#_addlistener)]
|
[!code-vb[RichTextBox_ContextMenu#_AddListener](~/samples/snippets/visualbasic/VS_Snippets_Wpf/RichTextBox_ContextMenu/VisualBasic/app.xaml.vb#_addlistener)]
|
||||||
|
|
||||||
## Example
|
## Implementation of ContextMenuOpening event listener
|
||||||
The following example shows an implementation the corresponding <xref:System.Windows.FrameworkContentElement.ContextMenuOpening> event listener.
|
The following example shows an implementation the corresponding <xref:System.Windows.FrameworkContentElement.ContextMenuOpening> event listener.
|
||||||
|
|
||||||
[!code-csharp[RichTextBox_ContextMenu#_ListenerBody](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBox_ContextMenu/CSharp/app.xaml.cs#_listenerbody)]
|
[!code-csharp[RichTextBox_ContextMenu#_ListenerBody](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBox_ContextMenu/CSharp/app.xaml.cs#_listenerbody)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Remove all Adorners from an Element"
|
title: "How to: Remove all Adorners from an Element"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn how to remove all Adorners from an Element.
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -11,13 +13,13 @@ ms.assetid: fe5303a3-b76e-4643-aafb-51419032b47b
|
|||||||
# How to: Remove all Adorners from an Element
|
# How to: Remove all Adorners from an Element
|
||||||
This example shows how to programmatically remove all adorners from a specified <xref:System.Windows.UIElement>.
|
This example shows how to programmatically remove all adorners from a specified <xref:System.Windows.UIElement>.
|
||||||
|
|
||||||
## Example
|
## Retrieve the adorners on a UIElement
|
||||||
This verbose code example removes all of the adorners in the array of adorners returned by <xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A>. This example happens to retrieve the adorners on a <xref:System.Windows.UIElement> named *myTextBox*. If the element specified in the call to <xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A> has no adorners, `null` is returned. This code explicitly checks for a null array, and is best suited for applications where a null array is expected to be relatively common.
|
This verbose code example removes all of the adorners in the array of adorners returned by <xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A>. This example happens to retrieve the adorners on a <xref:System.Windows.UIElement> named *myTextBox*. If the element specified in the call to <xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A> has no adorners, `null` is returned. This code explicitly checks for a null array, and is best suited for applications where a null array is expected to be relatively common.
|
||||||
|
|
||||||
[!code-csharp[AdornersMiscCode#_RemoveAllAdornersLong](~/samples/snippets/csharp/VS_Snippets_Wpf/AdornersMiscCode/CSharp/Window1.xaml.cs#_removealladornerslong)]
|
[!code-csharp[AdornersMiscCode#_RemoveAllAdornersLong](~/samples/snippets/csharp/VS_Snippets_Wpf/AdornersMiscCode/CSharp/Window1.xaml.cs#_removealladornerslong)]
|
||||||
[!code-vb[AdornersMiscCode#_RemoveAllAdornersLong](~/samples/snippets/visualbasic/VS_Snippets_Wpf/AdornersMiscCode/visualbasic/window1.xaml.vb#_removealladornerslong)]
|
[!code-vb[AdornersMiscCode#_RemoveAllAdornersLong](~/samples/snippets/visualbasic/VS_Snippets_Wpf/AdornersMiscCode/visualbasic/window1.xaml.vb#_removealladornerslong)]
|
||||||
|
|
||||||
## Example
|
## Code example
|
||||||
This condensed code example is functionally equivalent to the verbose example shown above. This code does not explicitly check for a null array, so it is possible that a <xref:System.NullReferenceException> exception may be raised. This code is best suited for applications where a null array is expected to be rare.
|
This condensed code example is functionally equivalent to the verbose example shown above. This code does not explicitly check for a null array, so it is possible that a <xref:System.NullReferenceException> exception may be raised. This code is best suited for applications where a null array is expected to be rare.
|
||||||
|
|
||||||
[!code-csharp[AdornersMiscCode#_RemoveAllAdornersShort](~/samples/snippets/csharp/VS_Snippets_Wpf/AdornersMiscCode/CSharp/Window1.xaml.cs#_removealladornersshort)]
|
[!code-csharp[AdornersMiscCode#_RemoveAllAdornersShort](~/samples/snippets/csharp/VS_Snippets_Wpf/AdornersMiscCode/CSharp/Window1.xaml.cs#_removealladornersshort)]
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Remove an Adorner from an Element"
|
title: "How to: Remove an Adorner from an Element"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn how to remove an Adorner from an Element.
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -11,7 +13,7 @@ ms.assetid: 97cf4d9f-0596-429e-8526-32a30aa4ae99
|
|||||||
# How to: Remove an Adorner from an Element
|
# How to: Remove an Adorner from an Element
|
||||||
This example shows how to programmatically remove a specific adorner from a specified <xref:System.Windows.UIElement>.
|
This example shows how to programmatically remove a specific adorner from a specified <xref:System.Windows.UIElement>.
|
||||||
|
|
||||||
## Example
|
## Retrieve an adorner on a UIElement
|
||||||
This verbose code example removes the first adorner in the array of adorners returned by <xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A>. This example happens to retrieve the adorners on a <xref:System.Windows.UIElement> named *myTextBox*. If the element specified in the call to <xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A> has no adorners, `null` is returned. This code explicitly checks for a null array, and is best suited for applications where a null array is expected to be relatively common.
|
This verbose code example removes the first adorner in the array of adorners returned by <xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A>. This example happens to retrieve the adorners on a <xref:System.Windows.UIElement> named *myTextBox*. If the element specified in the call to <xref:System.Windows.Documents.AdornerLayer.GetAdorners%2A> has no adorners, `null` is returned. This code explicitly checks for a null array, and is best suited for applications where a null array is expected to be relatively common.
|
||||||
|
|
||||||
[!code-csharp[AdornersMiscCode#_RemoveSpecificAdornerLong](~/samples/snippets/csharp/VS_Snippets_Wpf/AdornersMiscCode/CSharp/Window1.xaml.cs#_removespecificadornerlong)]
|
[!code-csharp[AdornersMiscCode#_RemoveSpecificAdornerLong](~/samples/snippets/csharp/VS_Snippets_Wpf/AdornersMiscCode/CSharp/Window1.xaml.cs#_removespecificadornerlong)]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Retrieve a Text Selection"
|
title: "How to: Retrieve a Text Selection"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn how to retrieve a Text selection.
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -13,14 +15,14 @@ ms.assetid: d5793172-1e11-4a39-9be0-73f336ed858d
|
|||||||
# How to: Retrieve a Text Selection
|
# How to: Retrieve a Text Selection
|
||||||
This example shows one way to use the <xref:System.Windows.Controls.TextBox.SelectedText%2A> property to retrieve text that the user has selected in a <xref:System.Windows.Controls.TextBox> control.
|
This example shows one way to use the <xref:System.Windows.Controls.TextBox.SelectedText%2A> property to retrieve text that the user has selected in a <xref:System.Windows.Controls.TextBox> control.
|
||||||
|
|
||||||
## Example
|
## Define a TextBox control
|
||||||
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] example shows the definition of a <xref:System.Windows.Controls.TextBox> control that contains some text to select, and a <xref:System.Windows.Controls.Button> control with a specified <xref:System.Windows.Controls.Button.OnClick%2A> method.
|
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] example shows the definition of a <xref:System.Windows.Controls.TextBox> control that contains some text to select, and a <xref:System.Windows.Controls.Button> control with a specified <xref:System.Windows.Controls.Button.OnClick%2A> method.
|
||||||
|
|
||||||
In this example, a button with an associated <xref:System.Windows.Controls.Primitives.ButtonBase.Click> event handler is used to retrieve the text selection. When the user clicks the button, the <xref:System.Windows.Controls.Button.OnClick%2A> method copies any selected text in the textbox into a string. The particular circumstances by which the text selection is retrieved (clicking a button), as well as the action taken with that selection (copying the text selection to a string), can easily be modified to accommodate a wide variety of scenarios.
|
In this example, a button with an associated <xref:System.Windows.Controls.Primitives.ButtonBase.Click> event handler is used to retrieve the text selection. When the user clicks the button, the <xref:System.Windows.Controls.Button.OnClick%2A> method copies any selected text in the textbox into a string. The particular circumstances by which the text selection is retrieved (clicking a button), as well as the action taken with that selection (copying the text selection to a string), can easily be modified to accommodate a wide variety of scenarios.
|
||||||
|
|
||||||
[!code-xaml[TextBox_MiscCode#_TextBoxSelectTextXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_textboxselecttextxaml)]
|
[!code-xaml[TextBox_MiscCode#_TextBoxSelectTextXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_textboxselecttextxaml)]
|
||||||
|
|
||||||
## Example
|
## OnClick event handler
|
||||||
The following C# example shows an <xref:System.Windows.Controls.Button.OnClick%2A> event handler for the button defined in the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] for this example.
|
The following C# example shows an <xref:System.Windows.Controls.Button.OnClick%2A> event handler for the button defined in the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] for this example.
|
||||||
|
|
||||||
[!code-csharp[TextBox_MiscCode#_SelectText](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml.cs#_selecttext)]
|
[!code-csharp[TextBox_MiscCode#_SelectText](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml.cs#_selecttext)]
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: "How to: Save, Load, and Print RichTextBox Content"
|
title: "How to: Save, Load, and Print RichTextBox Content"
|
||||||
ms.date: "03/30/2017"
|
ms.date: "03/30/2017"
|
||||||
|
ms.custom: devdivchpfy22
|
||||||
|
description: Learn how to Save, Load, and Print RichTextBox content.
|
||||||
dev_langs:
|
dev_langs:
|
||||||
- "csharp"
|
- "csharp"
|
||||||
- "vb"
|
- "vb"
|
||||||
@@ -16,12 +18,12 @@ ms.assetid: ffb113d3-c68a-47ca-8ac0-882283f38326
|
|||||||
# How to: Save, Load, and Print RichTextBox Content
|
# How to: Save, Load, and Print RichTextBox Content
|
||||||
The following example shows how to save content of a <xref:System.Windows.Controls.RichTextBox> to a file, load that content back into the <xref:System.Windows.Controls.RichTextBox>, and print the contents.
|
The following example shows how to save content of a <xref:System.Windows.Controls.RichTextBox> to a file, load that content back into the <xref:System.Windows.Controls.RichTextBox>, and print the contents.
|
||||||
|
|
||||||
## Example
|
## Markup for Save, Load, and Print RichTextBox Content
|
||||||
Below is the markup for the example.
|
Below is the markup for the example.
|
||||||
|
|
||||||
[!code-xaml[RichTextBoxMiscSnippets_snip#SaveLoadPrintRTBExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/SaveLoadPrintRTB.xaml#saveloadprintrtbexamplewholepage)]
|
[!code-xaml[RichTextBoxMiscSnippets_snip#SaveLoadPrintRTBExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/SaveLoadPrintRTB.xaml#saveloadprintrtbexamplewholepage)]
|
||||||
|
|
||||||
## Example
|
## Code for Save, Load, and Print RichTextBox Content
|
||||||
Below is the code behind for the example.
|
Below is the code behind for the example.
|
||||||
|
|
||||||
[!code-csharp[RichTextBoxMiscSnippets_snip#SaveLoadPrintRTBCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/SaveLoadPrintRTB.xaml.cs#saveloadprintrtbcodeexamplewholepage)]
|
[!code-csharp[RichTextBoxMiscSnippets_snip#SaveLoadPrintRTBCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/SaveLoadPrintRTB.xaml.cs#saveloadprintrtbcodeexamplewholepage)]
|
||||||
|
|||||||
+3
-2
@@ -2,6 +2,7 @@
|
|||||||
title: "How to: Set Focus in a TextBox Control"
|
title: "How to: Set Focus in a TextBox Control"
|
||||||
description: Learn how to use the Focus method to set focus on a Windows Presentation Foundation TextBox control.
|
description: Learn how to use the Focus method to set focus on 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"
|
||||||
@@ -13,12 +14,12 @@ ms.assetid: 24b61b45-dc2d-425e-9839-b017af7ab86f
|
|||||||
# How to: Set Focus in a TextBox Control
|
# How to: Set Focus in a TextBox Control
|
||||||
This example shows how to use the <xref:System.Windows.UIElement.Focus%2A> method to set focus on a <xref:System.Windows.Controls.TextBox> control.
|
This example shows how to use the <xref:System.Windows.UIElement.Focus%2A> method to set focus on a <xref:System.Windows.Controls.TextBox> control.
|
||||||
|
|
||||||
## Example
|
## Define a simple TextBox control
|
||||||
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] example describes a simple <xref:System.Windows.Controls.TextBox> control named *tbFocusMe*
|
The following [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] example describes a simple <xref:System.Windows.Controls.TextBox> control named *tbFocusMe*
|
||||||
|
|
||||||
[!code-xaml[TextBox_MiscCode#_TextBoxFocusXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_textboxfocusxaml)]
|
[!code-xaml[TextBox_MiscCode#_TextBoxFocusXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_textboxfocusxaml)]
|
||||||
|
|
||||||
## Example
|
## Set the focus on the TextBox control
|
||||||
The following example calls the <xref:System.Windows.UIElement.Focus%2A> method to set the focus on the <xref:System.Windows.Controls.TextBox> control with the Name *tbFocusMe*.
|
The following example calls the <xref:System.Windows.UIElement.Focus%2A> method to set the focus on the <xref:System.Windows.Controls.TextBox> control with the Name *tbFocusMe*.
|
||||||
|
|
||||||
[!code-csharp[TextBox_MiscCode#_FocusTextBox](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml.cs#_focustextbox)]
|
[!code-csharp[TextBox_MiscCode#_FocusTextBox](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml.cs#_focustextbox)]
|
||||||
|
|||||||
+3
-2
@@ -2,6 +2,7 @@
|
|||||||
title: "How to: Set the Text Content of a TextBox Control"
|
title: "How to: Set the Text Content of a TextBox Control"
|
||||||
description: Learn how to use the Text property to set the initial text contents of a Windows Presentation Foundation TextBox control.
|
description: Learn how to use the Text property to set the initial 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"
|
||||||
@@ -17,11 +18,11 @@ This example shows how to use the <xref:System.Windows.Controls.TextBox.Text%2A>
|
|||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Although the [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] version of the example could use the `<TextBox.Text>` tags around the text of each button's <xref:System.Windows.Controls.TextBox> content, it is not necessary because the <xref:System.Windows.Controls.TextBox> applies the <xref:System.Windows.Markup.ContentPropertyAttribute> attribute to the <xref:System.Windows.Controls.TextBox.Text%2A> property. For more information, see [XAML in WPF](../advanced/xaml-in-wpf.md).
|
> Although the [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] version of the example could use the `<TextBox.Text>` tags around the text of each button's <xref:System.Windows.Controls.TextBox> content, it is not necessary because the <xref:System.Windows.Controls.TextBox> applies the <xref:System.Windows.Markup.ContentPropertyAttribute> attribute to the <xref:System.Windows.Controls.TextBox.Text%2A> property. For more information, see [XAML in WPF](../advanced/xaml-in-wpf.md).
|
||||||
|
|
||||||
## Example
|
## Use the Text property to set the text contents
|
||||||
|
|
||||||
[!code-xaml[TextBox_MiscCode#_TextBoxSetTextXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_textboxsettextxaml)]
|
[!code-xaml[TextBox_MiscCode#_TextBoxSetTextXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_textboxsettextxaml)]
|
||||||
|
|
||||||
## Example
|
## Set the Text Content of a TextBox Control
|
||||||
|
|
||||||
[!code-csharp[TextBox_MiscCode#_TextBoxSetText](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml.cs#_textboxsettext)]
|
[!code-csharp[TextBox_MiscCode#_TextBoxSetText](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml.cs#_textboxsettext)]
|
||||||
[!code-vb[TextBox_MiscCode#_TextBoxSetText](~/samples/snippets/visualbasic/VS_Snippets_Wpf/TextBox_MiscCode/VisualBasic/Window1.xaml.vb#_textboxsettext)]
|
[!code-vb[TextBox_MiscCode#_TextBoxSetText](~/samples/snippets/visualbasic/VS_Snippets_Wpf/TextBox_MiscCode/VisualBasic/Window1.xaml.vb#_textboxsettext)]
|
||||||
|
|||||||
Reference in New Issue
Block a user