mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-04 00:56:03 +02:00
Merge pull request #1136 from dotnet/publish-19744
This commit is contained in:
@@ -20,7 +20,7 @@ Extensible Application Markup Language (XAML) defines a language component and t
|
||||
|
||||
<a name="prerequisites"></a>
|
||||
## Prerequisites
|
||||
This topic assumes that you have read [Routed Events Overview](routed-events-overview.md) and [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml).
|
||||
This topic assumes that you have read [Routed Events Overview](routed-events-overview.md) and [XAML in WPF](xaml-in-wpf.md).
|
||||
|
||||
<a name="Syntax"></a>
|
||||
## Attached Event Syntax
|
||||
|
||||
@@ -32,7 +32,7 @@ The following is an example of how you can set <xref:System.Windows.Controls.Doc
|
||||
|
||||
The usage is somewhat similar to a static property; you always reference the type <xref:System.Windows.Controls.DockPanel> that owns and registers the attached property, rather than referring to any instance specified by name.
|
||||
|
||||
Also, because an attached property in XAML is an attribute that you set in markup, only the set operation has any relevance. You cannot directly get a property in XAML, although there are some indirect mechanisms for comparing values, such as triggers in styles (for details, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)).
|
||||
Also, because an attached property in XAML is an attribute that you set in markup, only the set operation has any relevance. You cannot directly get a property in XAML, although there are some indirect mechanisms for comparing values, such as triggers in styles (for details, see [Styling and Templating](../controls/styles-templates-overview.md)).
|
||||
|
||||
### Attached Property Implementation in WPF
|
||||
|
||||
@@ -142,5 +142,5 @@ WPF defines several .NET attributes that are intended to provide information abo
|
||||
- <xref:System.Windows.DependencyProperty>
|
||||
- [Dependency Properties Overview](dependency-properties-overview.md)
|
||||
- [Custom Dependency Properties](custom-dependency-properties.md)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Register an Attached Property](how-to-register-an-attached-property.md)
|
||||
|
||||
@@ -42,7 +42,7 @@ A high percentage of classes in [!INCLUDE[TLA#tla_winclient](../../../includes/t
|
||||
|
||||
- Support for styling and storyboards. For more information, see <xref:System.Windows.Style> and [Storyboards Overview](../graphics-multimedia/storyboards-overview.md).
|
||||
|
||||
- Support for data binding. For more information, see [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
- Support for data binding. For more information, see [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
- Support for dynamic resource references. For more information, see [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define).
|
||||
|
||||
@@ -62,7 +62,7 @@ A high percentage of classes in [!INCLUDE[TLA#tla_winclient](../../../includes/t
|
||||
|
||||
- Support for styling and storyboards. For more information, see <xref:System.Windows.Style> and [Animation Overview](../graphics-multimedia/animation-overview.md).
|
||||
|
||||
- Support for data binding. For more information, see [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
- Support for data binding. For more information, see [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
- Support for dynamic resource references. For more information, see [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define).
|
||||
|
||||
|
||||
@@ -33,5 +33,5 @@ Four key classes--<xref:System.Windows.UIElement>, <xref:System.Windows.ContentE
|
||||
[Events](events-wpf.md)
|
||||
[Input](input-wpf.md)
|
||||
[Resources](resources-wpf.md)
|
||||
[Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
[Styling and Templating](../controls/styles-templates-overview.md)
|
||||
[Threading Model](threading-model.md)
|
||||
|
||||
@@ -38,7 +38,7 @@ Defers a property value to be a data-bound value, creating an intermediate expre
|
||||
|`path`|The path string that sets the implicit <xref:System.Windows.Data.Binding.Path%2A?displayProperty=nameWithType> property. See also [PropertyPath XAML Syntax](propertypath-xaml-syntax.md).|
|
||||
|
||||
## Unqualified {Binding}
|
||||
The `{Binding}` usage shown in "Binding Expression Usage" creates a <xref:System.Windows.Data.Binding> object with default values, which includes an initial <xref:System.Windows.Data.Binding.Path%2A?displayProperty=nameWithType> of `null`. This is still useful in many scenarios, because the created <xref:System.Windows.Data.Binding> might be relying on key data binding properties such as <xref:System.Windows.Data.Binding.Path%2A?displayProperty=nameWithType> and <xref:System.Windows.Data.Binding.Source%2A?displayProperty=nameWithType> being set in the run-time data context. For more information on the concept of data context, see [Data Binding](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
The `{Binding}` usage shown in "Binding Expression Usage" creates a <xref:System.Windows.Data.Binding> object with default values, which includes an initial <xref:System.Windows.Data.Binding.Path%2A?displayProperty=nameWithType> of `null`. This is still useful in many scenarios, because the created <xref:System.Windows.Data.Binding> might be relying on key data binding properties such as <xref:System.Windows.Data.Binding.Path%2A?displayProperty=nameWithType> and <xref:System.Windows.Data.Binding.Source%2A?displayProperty=nameWithType> being set in the run-time data context. For more information on the concept of data context, see [Data Binding](../data/data-binding-overview.md).
|
||||
|
||||
## Implicit Path
|
||||
The `Binding` markup extension uses <xref:System.Windows.Data.Binding.Path%2A?displayProperty=nameWithType> as a conceptual "default property", where `Path=` does not need to appear in the expression. If you specify a `Binding` expression with an implicit path, the implicit path must appear first in the expression, prior to any other `bindProp`=`value` pairs where the <xref:System.Windows.Data.Binding> property is specified by name. For example: `{Binding PathString}`, where `PathString` is a string that is evaluated to be the value of <xref:System.Windows.Data.Binding.Path%2A?displayProperty=nameWithType> in the <xref:System.Windows.Data.Binding> created by the markup extension usage. You can append an implicit path with other named properties after the comma separator, for example, `{Binding LastName, Mode=TwoWay}`.
|
||||
@@ -58,7 +58,7 @@ Defers a property value to be a data-bound value, creating an intermediate expre
|
||||
|
||||
- <xref:System.Windows.Data.Binding.ConverterParameter%2A>: can be set as a `bindProp`=`value` string in the expression, but this is dependent on the type of the parameter being passed. If passing a reference type for the value, this usage requires an object reference such as a nested [StaticResource Markup Extension](staticresource-markup-extension.md).
|
||||
|
||||
- <xref:System.Windows.Data.Binding.ElementName%2A>: mutually exclusive versus <xref:System.Windows.Data.Binding.RelativeSource%2A> and <xref:System.Windows.Data.Binding.Source%2A>; each of these binding properties represents a particular binding methodology. See [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
- <xref:System.Windows.Data.Binding.ElementName%2A>: mutually exclusive versus <xref:System.Windows.Data.Binding.RelativeSource%2A> and <xref:System.Windows.Data.Binding.Source%2A>; each of these binding properties represents a particular binding methodology. See [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
- <xref:System.Windows.Data.BindingBase.FallbackValue%2A>: can be set as a `bindProp`=`value` string in the expression, but this is dependent on the type of the value being passed. If passing a reference type, requires an object reference such as a nested [StaticResource Markup Extension](staticresource-markup-extension.md).
|
||||
|
||||
@@ -74,9 +74,9 @@ Defers a property value to be a data-bound value, creating an intermediate expre
|
||||
|
||||
- <xref:System.Windows.Data.Binding.Path%2A>: a string that describes a path into a data object or a general object model. The format provides several different conventions for traversing an object model that cannot be adequately described in this topic. See [PropertyPath XAML Syntax](propertypath-xaml-syntax.md).
|
||||
|
||||
- <xref:System.Windows.Data.Binding.RelativeSource%2A>: mutually exclusive versus with <xref:System.Windows.Data.Binding.ElementName%2A> and <xref:System.Windows.Data.Binding.Source%2A>; each of these binding properties represents a particular binding methodology. See [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview). Requires a nested [RelativeSource MarkupExtension](relativesource-markupextension.md) usage to specify the value.
|
||||
- <xref:System.Windows.Data.Binding.RelativeSource%2A>: mutually exclusive versus with <xref:System.Windows.Data.Binding.ElementName%2A> and <xref:System.Windows.Data.Binding.Source%2A>; each of these binding properties represents a particular binding methodology. See [Data Binding Overview](../data/data-binding-overview.md). Requires a nested [RelativeSource MarkupExtension](relativesource-markupextension.md) usage to specify the value.
|
||||
|
||||
- <xref:System.Windows.Data.Binding.Source%2A>: mutually exclusive versus <xref:System.Windows.Data.Binding.RelativeSource%2A> and <xref:System.Windows.Data.Binding.ElementName%2A>; each of these binding properties represents a particular binding methodology. See [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview). Requires a nested extension usage, typically a [StaticResource Markup Extension](staticresource-markup-extension.md) that refers to an object data source from a keyed resource dictionary.
|
||||
- <xref:System.Windows.Data.Binding.Source%2A>: mutually exclusive versus <xref:System.Windows.Data.Binding.RelativeSource%2A> and <xref:System.Windows.Data.Binding.ElementName%2A>; each of these binding properties represents a particular binding methodology. See [Data Binding Overview](../data/data-binding-overview.md). Requires a nested extension usage, typically a [StaticResource Markup Extension](staticresource-markup-extension.md) that refers to an object data source from a keyed resource dictionary.
|
||||
|
||||
- <xref:System.Windows.Data.BindingBase.StringFormat%2A>: a string that describes a string format convention for the bound data. This is a relatively advanced binding concept; see reference page for <xref:System.Windows.Data.BindingBase.StringFormat%2A>.
|
||||
|
||||
@@ -103,7 +103,7 @@ Defers a property value to be a data-bound value, creating an intermediate expre
|
||||
> [!IMPORTANT]
|
||||
> In terms of dependency property precedence, a `Binding` expression is equivalent to a locally set value. If you set a local value for a property that previously had a `Binding` expression, the `Binding` is completely removed. For details, see [Dependency Property Value Precedence](dependency-property-value-precedence.md).
|
||||
|
||||
Describing data binding at a basic level is not covered in this topic. See [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
Describing data binding at a basic level is not covered in this topic. See [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
> [!NOTE]
|
||||
> <xref:System.Windows.Data.MultiBinding> and <xref:System.Windows.Data.PriorityBinding> do not support a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] extension syntax. You would instead use property elements. See reference topics for <xref:System.Windows.Data.MultiBinding> and <xref:System.Windows.Data.PriorityBinding>.
|
||||
@@ -119,6 +119,6 @@ Defers a property value to be a data-bound value, creating an intermediate expre
|
||||
## See also
|
||||
|
||||
- <xref:System.Windows.Data.Binding>
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md)
|
||||
|
||||
@@ -23,11 +23,11 @@ ms.assetid: 9df6d3c9-aed3-471c-af36-6859b19d999f
|
||||
|
||||
<a name="Prerequisites"></a>
|
||||
## Prerequisites
|
||||
This topic assumes that you have read the [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml) and have some basic knowledge of the CLR and object-oriented programming.
|
||||
This topic assumes that you have read the [XAML in WPF](xaml-in-wpf.md) and have some basic knowledge of the CLR and object-oriented programming.
|
||||
|
||||
<a name="codebehind_and_the_xaml_language"></a>
|
||||
## Code-Behind and the XAML Language
|
||||
The XAML language includes language-level features that make it possible to associate code files with markup files, from the markup file side. Specifically, the XAML language defines the language features [x:Class Directive](/dotnet/desktop-wpf/xaml-services/xclass-directive), [x:Subclass Directive](/dotnet/desktop-wpf/xaml-services/xsubclass-directive), and [x:ClassModifier Directive](/dotnet/desktop-wpf/xaml-services/xclassmodifier-directive). Exactly how the code should be produced, and how to integrate markup and code, is not part of what the XAML language specifies. It is left up to frameworks such as WPF to determine how to integrate the code, how to use XAML in the application and programming models, and the build actions or other support that all this requires.
|
||||
The XAML language includes language-level features that make it possible to associate code files with markup files, from the markup file side. Specifically, the XAML language defines the language features [x:Class Directive](/dotnet/desktop/xaml-services/xclass-directive), [x:Subclass Directive](/dotnet/desktop/xaml-services/xsubclass-directive), and [x:ClassModifier Directive](/dotnet/desktop/xaml-services/xclassmodifier-directive). Exactly how the code should be produced, and how to integrate markup and code, is not part of what the XAML language specifies. It is left up to frameworks such as WPF to determine how to integrate the code, how to use XAML in the application and programming models, and the build actions or other support that all this requires.
|
||||
|
||||
<a name="Code_behind__Event_Handler__and_Partial_Class"></a>
|
||||
## Code-behind, Event Handler, and Partial Class Requirements in WPF
|
||||
@@ -44,17 +44,17 @@ ms.assetid: 9df6d3c9-aed3-471c-af36-6859b19d999f
|
||||
|
||||
<a name="x_Code"></a>
|
||||
## x:Code
|
||||
[x:Code](/dotnet/desktop-wpf/xaml-services/xcode-intrinsic-xaml-type) is a directive element defined in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)]. An `x:Code` directive element can contain inline programming code. The code that is defined inline can interact with the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] on the same page. The following example illustrates inline C# code. Notice that the code is inside the `x:Code` element and that the code must be surrounded by `<CDATA[`...`]]>` to escape the contents for XML, so that a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] processor (interpreting either the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] schema or the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] schema) will not try to interpret the contents literally as XML.
|
||||
[x:Code](/dotnet/desktop/xaml-services/xcode-intrinsic-xaml-type) is a directive element defined in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)]. An `x:Code` directive element can contain inline programming code. The code that is defined inline can interact with the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] on the same page. The following example illustrates inline C# code. Notice that the code is inside the `x:Code` element and that the code must be surrounded by `<CDATA[`...`]]>` to escape the contents for XML, so that a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] processor (interpreting either the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] schema or the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] schema) will not try to interpret the contents literally as XML.
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#ButtonWithInlineCode](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/page4.xaml#buttonwithinlinecode)]
|
||||
|
||||
<a name="Inline_Code_Limitations"></a>
|
||||
## Inline Code Limitations
|
||||
You should consider avoiding or limiting the use of inline code. In terms of architecture and coding philosophy, maintaining a separation between markup and code-behind keeps the designer and developer roles much more distinct. On a more technical level, the code that you write for inline code can be awkward to write, because you are always writing into the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] generated partial class, and can only use the default XML namespace mappings. Because you cannot add `using` statements, you must fully qualify many of the API calls that you make. The default [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] mappings include most but not all CLR namespaces that are present in the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] assemblies; you will have to fully qualify calls to types and members contained within the other CLR namespaces. You also cannot define anything beyond the partial class in the inline code, and all user code entities you reference must exist as a member or variable within the generated partial class. Other language specific programming features, such as macros or `#ifdef` against global variables or build variables, are also not available. For more information, see [x:Code Intrinsic XAML Type](/dotnet/desktop-wpf/xaml-services/xcode-intrinsic-xaml-type).
|
||||
You should consider avoiding or limiting the use of inline code. In terms of architecture and coding philosophy, maintaining a separation between markup and code-behind keeps the designer and developer roles much more distinct. On a more technical level, the code that you write for inline code can be awkward to write, because you are always writing into the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] generated partial class, and can only use the default XML namespace mappings. Because you cannot add `using` statements, you must fully qualify many of the API calls that you make. The default [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] mappings include most but not all CLR namespaces that are present in the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] assemblies; you will have to fully qualify calls to types and members contained within the other CLR namespaces. You also cannot define anything beyond the partial class in the inline code, and all user code entities you reference must exist as a member or variable within the generated partial class. Other language specific programming features, such as macros or `#ifdef` against global variables or build variables, are also not available. For more information, see [x:Code Intrinsic XAML Type](/dotnet/desktop/xaml-services/xcode-intrinsic-xaml-type).
|
||||
|
||||
## See also
|
||||
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [x:Code Intrinsic XAML Type](/dotnet/desktop-wpf/xaml-services/xcode-intrinsic-xaml-type)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [x:Code Intrinsic XAML Type](/dotnet/desktop/xaml-services/xcode-intrinsic-xaml-type)
|
||||
- [Building a WPF Application](../app-development/building-a-wpf-application-wpf.md)
|
||||
- [XAML Syntax In Detail](xaml-syntax-in-detail.md)
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ This topic provides guidance and suggested patterns for how to implement a depen
|
||||
|
||||
- <xref:System.Windows.FreezableCollection%601>
|
||||
- [XAML and Custom Classes for WPF](xaml-and-custom-classes-for-wpf.md)
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Dependency Properties Overview](dependency-properties-overview.md)
|
||||
- [Custom Dependency Properties](custom-dependency-properties.md)
|
||||
- [Dependency Property Metadata](dependency-property-metadata.md)
|
||||
|
||||
+3
-3
@@ -41,7 +41,7 @@ Defines and references keys for resources that are loaded from external assembli
|
||||
|||
|
||||
|-|-|
|
||||
|`targetTypeName`|The name of the public common language runtime (CLR) type that is defined in the resource assembly.|
|
||||
|`targetID`|The key for the resource. When resources are looked up, `targetID` will be analogous to the [x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive) of the resource.|
|
||||
|`targetID`|The key for the resource. When resources are looked up, `targetID` will be analogous to the [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive) of the resource.|
|
||||
|
||||
## Remarks
|
||||
As seen in the usages above, a {`ComponentResourceKey`} markup extension usage is found in two places:
|
||||
@@ -60,7 +60,7 @@ Defines and references keys for resources that are loaded from external assembli
|
||||
|
||||
The compact syntax shown relies on the <xref:System.Windows.ComponentResourceKey.%23ctor%2A> constructor signature and positional parameter usage of a markup extension. The order in which the `targetTypeName` and `targetID` are given is important. The verbose syntax relies on the <xref:System.Windows.ComponentResourceKey.%23ctor%2A> parameterless constructor, and then sets the <xref:System.Windows.ComponentResourceKey.TypeInTargetAssembly%2A> and <xref:System.Windows.ComponentResourceKey.ResourceId%2A> in a way that is analogous to a true attribute syntax on an object element. In the verbose syntax, the order in which the properties are set is not important. The relationship and mechanisms of these two alternatives (compact and verbose) is described in more detail in the topic [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md).
|
||||
|
||||
Technically, the value for `targetID` can be any object, it does not have to be a string. However, the most common usage in WPF is to align the `targetID` value with forms that are strings, and where such strings are valid in the [XamlName Grammar](/dotnet/desktop-wpf/xaml-services/xamlname-grammar).
|
||||
Technically, the value for `targetID` can be any object, it does not have to be a string. However, the most common usage in WPF is to align the `targetID` value with forms that are strings, and where such strings are valid in the [XamlName Grammar](/dotnet/desktop/xaml-services/xamlname-grammar).
|
||||
|
||||
`ComponentResourceKey` can be used in object element syntax. In this case, specifying the value of both the <xref:System.Windows.ComponentResourceKey.TypeInTargetAssembly%2A> and <xref:System.Windows.ComponentResourceKey.ResourceId%2A> properties is required to properly initialize the extension.
|
||||
|
||||
@@ -73,5 +73,5 @@ Defines and references keys for resources that are loaded from external assembli
|
||||
- <xref:System.Windows.ComponentResourceKey>
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Authoring Overview](../controls/control-authoring-overview.md)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md)
|
||||
|
||||
@@ -47,7 +47,7 @@ As mentioned in the [Dependency Properties Overview](dependency-properties-overv
|
||||
|
||||
When you implement a property on a class, so long as your class derives from <xref:System.Windows.DependencyObject>, you have the option to back your property with a <xref:System.Windows.DependencyProperty> identifier and thus to make it a dependency property. Having your property be a dependency property is not always necessary or appropriate, and will depend on your scenario needs. Sometimes, the typical technique of backing your property with a private field is adequate. However, you should implement your property as a dependency property whenever you want your property to support one or more of the following [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] capabilities:
|
||||
|
||||
- You want your property to be settable in a style. For more information, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
- You want your property to be settable in a style. For more information, see [Styling and Templating](../controls/styles-templates-overview.md).
|
||||
|
||||
- You want your property to support data binding. For more information about data binding dependency properties, see [Bind the Properties of Two Controls](../data/how-to-bind-the-properties-of-two-controls.md).
|
||||
|
||||
|
||||
@@ -69,4 +69,4 @@ Some controls, such as <xref:System.Windows.Controls.Calendar> and <xref:System.
|
||||
|
||||
## See also
|
||||
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
|
||||
@@ -56,7 +56,7 @@ The following XAML example specifies the background color of a button as red. Th
|
||||
|
||||
[!code-xaml[PropertiesOvwSupport#MostBasicProperty](~/samples/snippets/csharp/VS_Snippets_Wpf/PropertiesOvwSupport/CSharp/Page1.xaml#mostbasicproperty)]
|
||||
|
||||
XAML supports a variety of syntax forms for setting properties. Which syntax to use for a particular property will depend on the value type that a property uses, as well as other factors such as the presence of a type converter. For more information on XAML syntax for property setting, see [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml) and [XAML Syntax In Detail](xaml-syntax-in-detail.md).
|
||||
XAML supports a variety of syntax forms for setting properties. Which syntax to use for a particular property will depend on the value type that a property uses, as well as other factors such as the presence of a type converter. For more information on XAML syntax for property setting, see [XAML in WPF](xaml-in-wpf.md) and [XAML Syntax In Detail](xaml-syntax-in-detail.md).
|
||||
|
||||
As an example of non-attribute syntax, the following XAML example shows another button background. This time rather than setting a simple solid color, the background is set to an image, with an element representing that image and the source of that image specified as an attribute of the nested element. This is an example of property element syntax.
|
||||
|
||||
@@ -118,7 +118,7 @@ The following example sets the <xref:System.Windows.Controls.ContentControl.Cont
|
||||
> [!NOTE]
|
||||
> Bindings are treated as a local value, which means that if you set another local value, you will eliminate the binding. For details, see [Dependency Property Value Precedence](dependency-property-value-precedence.md).
|
||||
|
||||
Dependency properties, or the <xref:System.Windows.DependencyObject> class, do not natively support <xref:System.ComponentModel.INotifyPropertyChanged> for purposes of producing notifications of changes in <xref:System.Windows.DependencyObject> source property value for data binding operations. For more information on how to create properties for use in data binding that can report changes to a data binding target, see [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
Dependency properties, or the <xref:System.Windows.DependencyObject> class, do not natively support <xref:System.ComponentModel.INotifyPropertyChanged> for purposes of producing notifications of changes in <xref:System.Windows.DependencyObject> source property value for data binding operations. For more information on how to create properties for use in data binding that can report changes to a data binding target, see [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
### Styles
|
||||
Styles and templates are two of the chief motivating scenarios for using dependency properties. Styles are particularly useful for setting properties that define application [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)]. Styles are typically defined as resources in XAML. Styles interact with the property system because they typically contain "setters" for particular properties, as well as "triggers" that change a property value based on the real-time value for another property.
|
||||
@@ -129,7 +129,7 @@ The following example creates a simple style (which would be defined inside a <x
|
||||
|
||||
[!code-xaml[PropertiesOvwSupport#SimpleStyle](~/samples/snippets/csharp/VS_Snippets_Wpf/PropertiesOvwSupport/CSharp/page3.xaml#simplestyle)]
|
||||
|
||||
For more information, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
For more information, see [Styling and Templating](../controls/styles-templates-overview.md).
|
||||
|
||||
### Animations
|
||||
Dependency properties can be animated. When an animation is applied and is running, the animated value operates at a higher precedence than any value (such as a local value) that the property otherwise has.
|
||||
@@ -195,5 +195,5 @@ Typically, you would not want styles to always apply and to obscure even a local
|
||||
|
||||
- [Custom Dependency Properties](custom-dependency-properties.md)
|
||||
- [Read-Only Dependency Properties](read-only-dependency-properties.md)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [WPF Architecture](wpf-architecture.md)
|
||||
|
||||
@@ -32,7 +32,7 @@ Provides a value for any [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla
|
||||
|
||||
|||
|
||||
|-|-|
|
||||
|`key`|The key for the requested resource. This key was initially assigned by the [x:Key Directive](/dotnet/desktop-wpf/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
|
||||
A `DynamicResource` will create a temporary expression during the initial compilation and thus defer lookup for resources until the requested resource value is actually required in order to construct an object. This may potentially be after the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] page is loaded. The resource value will be found based on key search against all active resource dictionaries starting from the current page scope, and is substituted for the placeholder expression from compilation.
|
||||
@@ -42,9 +42,9 @@ Provides a value for any [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla
|
||||
|
||||
Certain resource access scenarios are particularly appropriate for `DynamicResource` as opposed to a [StaticResource Markup Extension](staticresource-markup-extension.md). See [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define) for a discussion about the relative merits and performance implications of `DynamicResource` and `StaticResource`.
|
||||
|
||||
The specified <xref:System.Windows.DynamicResourceExtension.ResourceKey%2A> should correspond to an existing resource determined by [x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive) at some level in your page, application, the available control themes and external resources, or system resources, and the resource lookup will happen in that order. For more information about resource lookup for static and dynamic resources, see [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define).
|
||||
The specified <xref:System.Windows.DynamicResourceExtension.ResourceKey%2A> should correspond to an existing resource determined by [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive) at some level in your page, application, the available control themes and external resources, or system resources, and the resource lookup will happen in that order. For more information about resource lookup for static and dynamic resources, see [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define).
|
||||
|
||||
A resource key may be any string defined in the [XamlName Grammar](/dotnet/desktop-wpf/xaml-services/xamlname-grammar). A resource key may also be other object types, such as a <xref:System.Type>. A <xref:System.Type> key is fundamental to how controls can be styled by themes. For more information, see [Control Authoring Overview](../controls/control-authoring-overview.md).
|
||||
A resource key may be any string defined in the [XamlName Grammar](/dotnet/desktop/xaml-services/xamlname-grammar). A resource key may also be other object types, such as a <xref:System.Type>. A <xref:System.Type> key is fundamental to how controls can be styled by themes. For more information, see [Control Authoring Overview](../controls/control-authoring-overview.md).
|
||||
|
||||
APIs for lookup of resource values, such as <xref:System.Windows.FrameworkElement.FindResource%2A>, follow the same resource lookup logic as used by `DynamicResource`.
|
||||
|
||||
@@ -70,8 +70,8 @@ Provides a value for any [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla
|
||||
|
||||
- [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define)
|
||||
- [Resources and Code](resources-and-code.md)
|
||||
- [x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md)
|
||||
- [StaticResource Markup Extension](staticresource-markup-extension.md)
|
||||
- [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md)
|
||||
|
||||
@@ -33,5 +33,5 @@ WPF programming elements often exist in some form of tree relationship to each o
|
||||
[Events](events-wpf.md)
|
||||
[Input](input-wpf.md)
|
||||
[Resources](resources-wpf.md)
|
||||
[Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
[Styling and Templating](../controls/styles-templates-overview.md)
|
||||
[Threading Model](threading-model.md)
|
||||
|
||||
@@ -38,6 +38,6 @@ ms.assetid: d3b93c6f-aa6b-486d-a010-d097ea8a516b
|
||||
[Properties](properties-wpf.md)
|
||||
[Input](input-wpf.md)
|
||||
[Resources](resources-wpf.md)
|
||||
[Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
[Styling and Templating](../controls/styles-templates-overview.md)
|
||||
[WPF Content Model](../controls/wpf-content-model.md)
|
||||
[Threading Model](threading-model.md)
|
||||
|
||||
@@ -26,7 +26,7 @@ Framework property metadata options are reported for the properties of object el
|
||||
> [!NOTE]
|
||||
> The term "inherits" in the context of property values means something specific for dependency properties; it means that child elements can inherit the actual dependency property value from parent elements because of a WPF framework-level capability of the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] property system. It has nothing to do directly with managed code type and members inheritance through derived types. For details, see [Property Value Inheritance](property-value-inheritance.md).
|
||||
|
||||
- Reporting data binding characteristics (<xref:System.Windows.FrameworkPropertyMetadata.IsNotDataBindable%2A>, <xref:System.Windows.FrameworkPropertyMetadata.BindsTwoWayByDefault%2A>). By default, dependency properties in the framework support data binding, with a one-way binding behavior. You might disable data binding if there were no scenario for it whatsoever (because they are intended to be flexible and extensible, there aren't many examples of such properties in the default [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] APIs). You might set binding to have a two-way default for properties that tie together a control's behaviors amongst its component pieces (<xref:System.Windows.Controls.MenuItem.IsSubmenuOpen%2A> is an example) or where two-way binding is the common and expected scenario for users (<xref:System.Windows.Controls.TextBox.Text%2A> is an example). Changing the data binding–related metadata only influences the default; on a per-binding basis that default can always be changed. For details on the binding modes and binding in general, see [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
- Reporting data binding characteristics (<xref:System.Windows.FrameworkPropertyMetadata.IsNotDataBindable%2A>, <xref:System.Windows.FrameworkPropertyMetadata.BindsTwoWayByDefault%2A>). By default, dependency properties in the framework support data binding, with a one-way binding behavior. You might disable data binding if there were no scenario for it whatsoever (because they are intended to be flexible and extensible, there aren't many examples of such properties in the default [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] APIs). You might set binding to have a two-way default for properties that tie together a control's behaviors amongst its component pieces (<xref:System.Windows.Controls.MenuItem.IsSubmenuOpen%2A> is an example) or where two-way binding is the common and expected scenario for users (<xref:System.Windows.Controls.TextBox.Text%2A> is an example). Changing the data binding–related metadata only influences the default; on a per-binding basis that default can always be changed. For details on the binding modes and binding in general, see [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
- Reporting whether properties should be journaled by applications or services that support journaling (<xref:System.Windows.FrameworkPropertyMetadata.Journal%2A>). For general elements, journaling is not enabled by default, but it is selectively enabled for certain user input controls. This property is intended to be read by journaling services including the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] implementation of journaling, and is typically set on user controls such as user selections within lists that should be persisted across navigation steps. For information about the journal, see [Navigation Overview](../app-development/navigation-overview.md).
|
||||
|
||||
|
||||
@@ -30,6 +30,6 @@ ms.assetid: e96f9764-4e3f-4d1c-bf20-3fb890118aae
|
||||
|
||||
<xref:System.Resources.NeutralResourcesLanguageAttribute>
|
||||
|
||||
[xml:lang Handling in XAML](/dotnet/desktop-wpf/xaml-services/xml-language-handling)
|
||||
[xml:lang Handling in XAML](/dotnet/desktop/xaml-services/xml-language-handling)
|
||||
|
||||
## Related Sections
|
||||
|
||||
@@ -39,7 +39,7 @@ The following example shows a hexadecimal character reference. Notice that it ha
|
||||
|
||||
<a name="lang_attrib"></a>
|
||||
### Language Attribute
|
||||
[!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] uses [xml:lang](/dotnet/desktop-wpf/xaml-services/xml-language-handling) to represent the language attribute of an element. To take advantage of the <xref:System.Globalization.CultureInfo> class, the language attribute value needs to be one of the culture names predefined by <xref:System.Globalization.CultureInfo>. [xml:lang](/dotnet/desktop-wpf/xaml-services/xml-language-handling) is inheritable in the element tree (by XML rules, not necessarily because of dependency property inheritance) and its default value is an empty string if it is not assigned explicitly.
|
||||
[!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] uses [xml:lang](/dotnet/desktop/xaml-services/xml-language-handling) to represent the language attribute of an element. To take advantage of the <xref:System.Globalization.CultureInfo> class, the language attribute value needs to be one of the culture names predefined by <xref:System.Globalization.CultureInfo>. [xml:lang](/dotnet/desktop/xaml-services/xml-language-handling) is inheritable in the element tree (by XML rules, not necessarily because of dependency property inheritance) and its default value is an empty string if it is not assigned explicitly.
|
||||
|
||||
The language attribute is very useful for specifying dialects. For example, French has different spelling, vocabulary, and pronunciation in France, Quebec, Belgium, and Switzerland. Also Chinese, Japanese, and Korean share code points in Unicode, but the ideographic shapes are different and they use totally different fonts.
|
||||
|
||||
@@ -143,7 +143,7 @@ The following example shows a hexadecimal character reference. Notice that it ha
|
||||
### Localizable User Interface
|
||||
[!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications use [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] to define their [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)]. [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] allows developers to specify a hierarchy of objects with a set of properties and logic. The primary use of [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] is to develop [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications but it can be used to specify a hierarchy of any common language runtime (CLR) objects. Most developers use [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] to specify their application's [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] and use a programming language such as C# to react to user interaction.
|
||||
|
||||
From a resource point of view, a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] file designed to describe a language-dependent [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] is a resource element and therefore its final distribution format must be localizable to support international languages. Because [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] cannot handle events many [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] applications contain blocks of code to do this. For more information, see [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml). Code is stripped out and compiled into different binaries when a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] file is tokenized into the BAML form of XAML. The BAML form of XAML files, images, and other types of managed resource objects are embedded in the satellite resource assembly, which can be localized into other languages, or the main assembly when localization is not required.
|
||||
From a resource point of view, a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] file designed to describe a language-dependent [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] is a resource element and therefore its final distribution format must be localizable to support international languages. Because [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] cannot handle events many [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] applications contain blocks of code to do this. For more information, see [XAML in WPF](xaml-in-wpf.md). Code is stripped out and compiled into different binaries when a [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] file is tokenized into the BAML form of XAML. The BAML form of XAML files, images, and other types of managed resource objects are embedded in the satellite resource assembly, which can be localized into other languages, or the main assembly when localization is not required.
|
||||
|
||||
> [!NOTE]
|
||||
> [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications support all the FrameworkCLR resources including string tables, images, and so forth.
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ This example shows how to add an event handler to an element by using code.
|
||||
[!code-vb[RoutedEventAddRemoveHandler#Handler](~/samples/snippets/visualbasic/VS_Snippets_Wpf/RoutedEventAddRemoveHandler/VisualBasic/default.xaml.vb#handler)]
|
||||
|
||||
> [!NOTE]
|
||||
> Adding an event handler in the initially parsed [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] page is much simpler. Within the object element where you want to add the event handler, add an attribute that matches the name of the event that you want to handle. Then specify the value of that attribute as the name of the event handler method that you defined in the code-behind file of the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] page. For more information, see [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml) or [Routed Events Overview](routed-events-overview.md).
|
||||
> Adding an event handler in the initially parsed [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] page is much simpler. Within the object element where you want to add the event handler, add an attribute that matches the name of the event that you want to handle. Then specify the value of that attribute as the name of the event handler method that you defined in the code-behind file of the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] page. For more information, see [XAML in WPF](xaml-in-wpf.md) or [Routed Events Overview](routed-events-overview.md).
|
||||
|
||||
## See also
|
||||
|
||||
|
||||
+1
-1
@@ -23,5 +23,5 @@ This example shows you how to create a focus visual style in resources and apply
|
||||
## See also
|
||||
|
||||
- <xref:System.Windows.FrameworkElement.FocusVisualStyle%2A>
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
- [Styling for Focus in Controls, and FocusVisualStyle](styling-for-focus-in-controls-and-focusvisualstyle.md)
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ This example shows how to change the color of an element as the mouse pointer en
|
||||
This example consists of a [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] file and a code-behind file.
|
||||
|
||||
> [!NOTE]
|
||||
> This example demonstrates how to use events, but the recommended way to achieve this same effect is to use a <xref:System.Windows.Trigger> in a style. For more information, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
> This example demonstrates how to use events, but the recommended way to achieve this same effect is to use a <xref:System.Windows.Trigger> in a style. For more information, see [Styling and Templating](../controls/styles-templates-overview.md).
|
||||
|
||||
## Example
|
||||
The following XAML creates the user interface, which consists of <xref:System.Windows.Controls.Border> around a <xref:System.Windows.Controls.TextBlock>, and attaches the <xref:System.Windows.Input.Mouse.MouseEnter> and <xref:System.Windows.UIElement.MouseLeave> event handlers to the <xref:System.Windows.Controls.Border>.
|
||||
|
||||
+1
-1
@@ -24,4 +24,4 @@ Note that one of the properties within the setters of the `Label` style also ref
|
||||
## See also
|
||||
|
||||
- [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
|
||||
@@ -29,7 +29,7 @@ The following is the class definition:
|
||||
[!code-csharp[ImplementICommandSource#ImplementICommandSourceClassDefinition](~/samples/snippets/csharp/VS_Snippets_Wpf/ImplementICommandSource/CSharp/CommandSlider.cs#implementicommandsourceclassdefinition)]
|
||||
[!code-vb[ImplementICommandSource#ImplementICommandSourceClassDefinition](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ImplementICommandSource/visualbasic/commandslider.vb#implementicommandsourceclassdefinition)]
|
||||
|
||||
The next step is to implement the <xref:System.Windows.Input.ICommandSource> members. In this example, the properties are implemented as <xref:System.Windows.DependencyProperty> objects. This enables the properties to use data binding. For more information about the <xref:System.Windows.DependencyProperty> class, see the [Dependency Properties Overview](dependency-properties-overview.md). For more information about data binding, see the [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
The next step is to implement the <xref:System.Windows.Input.ICommandSource> members. In this example, the properties are implemented as <xref:System.Windows.DependencyProperty> objects. This enables the properties to use data binding. For more information about the <xref:System.Windows.DependencyProperty> class, see the [Dependency Properties Overview](dependency-properties-overview.md). For more information about data binding, see the [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
Only the <xref:System.Windows.Input.ICommandSource.Command%2A> property is shown here.
|
||||
|
||||
|
||||
@@ -37,6 +37,6 @@ This example shows how to use the static resources of the <xref:System.Windows.S
|
||||
- [Use SystemParameters](how-to-use-systemparameters.md)
|
||||
- [Use System Fonts Keys](how-to-use-system-fonts-keys.md)
|
||||
- [How-to Topics](resources-how-to-topics.md)
|
||||
- [x:Static Markup Extension](/dotnet/desktop-wpf/xaml-services/xstatic-markup-extension)
|
||||
- [x:Static Markup Extension](/dotnet/desktop/xaml-services/xstatic-markup-extension)
|
||||
- [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define)
|
||||
- [DynamicResource Markup Extension](dynamicresource-markup-extension.md)
|
||||
|
||||
+1
-1
@@ -38,4 +38,4 @@ Some aspects of [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-wincl
|
||||
|
||||
- [Trees in WPF](trees-in-wpf.md)
|
||||
- [WPF Graphics Rendering Overview](../graphics-multimedia/wpf-graphics-rendering-overview.md)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
|
||||
@@ -32,4 +32,4 @@ ms.assetid: 69a1a3f9-acb5-4e2c-9c43-2e376c055ac4
|
||||
|
||||
## See also
|
||||
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
|
||||
@@ -35,13 +35,13 @@ This topic introduces the concept of markup extensions for XAML, including their
|
||||
## XAML-Defined Markup Extensions
|
||||
Several markup extensions exist that are not specific to the WPF implementation of XAML, but are instead implementations of intrinsics or features of XAML as a language. These markup extensions are implemented in the System.Xaml assembly as part of the general .NET Framework XAML services, and are within the XAML language XAML namespace. In terms of common markup usage, these markup extensions are typically identifiable by the `x:` prefix in the usage. The <xref:System.Windows.Markup.MarkupExtension> base class (also defined in System.Xaml) provides the pattern that all markup extensions should use in order to be supported in XAML readers and XAML writers, including in WPF XAML.
|
||||
|
||||
- `x:Type` supplies the <xref:System.Type> object for the named type. This facility is used most frequently in styles and templates. For details, see [x:Type Markup Extension](/dotnet/desktop-wpf/xaml-services/xtype-markup-extension).
|
||||
- `x:Type` supplies the <xref:System.Type> object for the named type. This facility is used most frequently in styles and templates. For details, see [x:Type Markup Extension](/dotnet/desktop/xaml-services/xtype-markup-extension).
|
||||
|
||||
- `x:Static` produces static values. The values come from value-type code entities that are not directly the type of a target property's value, but can be evaluated to that type. For details, see [x:Static Markup Extension](/dotnet/desktop-wpf/xaml-services/xstatic-markup-extension).
|
||||
- `x:Static` produces static values. The values come from value-type code entities that are not directly the type of a target property's value, but can be evaluated to that type. For details, see [x:Static Markup Extension](/dotnet/desktop/xaml-services/xstatic-markup-extension).
|
||||
|
||||
- `x:Null` specifies `null` as a value for a property and can be used either for attributes or property element values. For details, see [x:Null Markup Extension](/dotnet/desktop-wpf/xaml-services/xnull-markup-extension).
|
||||
- `x:Null` specifies `null` as a value for a property and can be used either for attributes or property element values. For details, see [x:Null Markup Extension](/dotnet/desktop/xaml-services/xnull-markup-extension).
|
||||
|
||||
- `x:Array` provides support for creation of general arrays in XAML syntax, for cases where the collection support provided by WPF base elements and control models is deliberately not used. For details, see [x:Array Markup Extension](/dotnet/desktop-wpf/xaml-services/xarray-markup-extension).
|
||||
- `x:Array` provides support for creation of general arrays in XAML syntax, for cases where the collection support provided by WPF base elements and control models is deliberately not used. For details, see [x:Array Markup Extension](/dotnet/desktop/xaml-services/xarray-markup-extension).
|
||||
|
||||
> [!NOTE]
|
||||
> The `x:` prefix is used for the typical XAML namespace mapping of the XAML language intrinsics, in the root element of a XAML file or production. For example, the Visual Studio templates for WPF applications initiate a XAML file using this `x:` mapping. You could choose a different prefix token in your own XAML namespace mapping, but this documentation will assume the default `x:` mapping as a means of identifying those entities that are a defined part of the XAML namespace for the XAML language, as opposed to the WPF default namespace or other XAML namespaces not related to a specific framework.
|
||||
@@ -92,7 +92,7 @@ This topic introduces the concept of markup extensions for XAML, including their
|
||||
|
||||
<a name="EscapeSequences"></a>
|
||||
## Escape Sequences and Markup Extensions
|
||||
Attribute handling in a XAML processor uses the curly braces as indicators of a markup extension sequence. It is also possible to produce a literal curly brace character attribute value if necessary, by entering an escape sequence using an empty curly brace pair followed by the literal curly brace. See [{} Escape Sequence - Markup Extension](/dotnet/desktop-wpf/xaml-services/escape-sequence-markup-extension).
|
||||
Attribute handling in a XAML processor uses the curly braces as indicators of a markup extension sequence. It is also possible to produce a literal curly brace character attribute value if necessary, by entering an escape sequence using an empty curly brace pair followed by the literal curly brace. See [{} Escape Sequence - Markup Extension](/dotnet/desktop/xaml-services/escape-sequence-markup-extension).
|
||||
|
||||
<a name="Nesting"></a>
|
||||
## Nesting Markup Extensions in XAML Usage
|
||||
@@ -108,14 +108,14 @@ This topic introduces the concept of markup extensions for XAML, including their
|
||||
## Markup Extensions and Property Element Syntax
|
||||
When used as an object element that fills a property element value, a markup extension class is visually indistinguishable from a typical type-backed object element that can be used in XAML. The practical difference between a typical object element and a markup extension is that the markup extension is either evaluated to a typed value or deferred as an expression. Therefore the mechanisms for any possible type errors of property values for the markup extension will be different, similar to how a late-bound property is treated in other programming models. An ordinary object element will be evaluated for type match against the target property it is setting when the XAML is parsed.
|
||||
|
||||
Most markup extensions, when used in object element syntax to fill a property element, would not have content or any further property element syntax within. Thus you would close the object element tag, and provide no child elements. Whenever any object element is encountered by a XAML processor, the constructor for that class is called, which instantiates the object created from the parsed element. A markup extension class is no different: if you want your markup extension to be usable in object element syntax, you must provide a parameterless constructor. Some existing markup extensions have at least one required property value that must be specified for effective initialization. If so, that property value is typically given as a property attribute on the object element. In the [XAML Namespace (x:) Language Features](/dotnet/desktop-wpf/xaml-services/namespace-language-features) and [WPF XAML Extensions](wpf-xaml-extensions.md) reference pages, markup extensions that have required properties (and the names of required properties) will be noted. Reference pages will also note if either object element syntax or attribute syntax is disallowed for particular markup extensions. A notable case is [x:Array Markup Extension](/dotnet/desktop-wpf/xaml-services/xarray-markup-extension), which cannot support attribute syntax because the contents of that array must be specified within the tagging as content. The array contents are handled as general objects, therefore no default type converter for the attribute is feasible. Also, [x:Array Markup Extension](/dotnet/desktop-wpf/xaml-services/xarray-markup-extension) requires a `type` parameter.
|
||||
Most markup extensions, when used in object element syntax to fill a property element, would not have content or any further property element syntax within. Thus you would close the object element tag, and provide no child elements. Whenever any object element is encountered by a XAML processor, the constructor for that class is called, which instantiates the object created from the parsed element. A markup extension class is no different: if you want your markup extension to be usable in object element syntax, you must provide a parameterless constructor. Some existing markup extensions have at least one required property value that must be specified for effective initialization. If so, that property value is typically given as a property attribute on the object element. In the [XAML Namespace (x:) Language Features](/dotnet/desktop/xaml-services/namespace-language-features) and [WPF XAML Extensions](wpf-xaml-extensions.md) reference pages, markup extensions that have required properties (and the names of required properties) will be noted. Reference pages will also note if either object element syntax or attribute syntax is disallowed for particular markup extensions. A notable case is [x:Array Markup Extension](/dotnet/desktop/xaml-services/xarray-markup-extension), which cannot support attribute syntax because the contents of that array must be specified within the tagging as content. The array contents are handled as general objects, therefore no default type converter for the attribute is feasible. Also, [x:Array Markup Extension](/dotnet/desktop/xaml-services/xarray-markup-extension) requires a `type` parameter.
|
||||
|
||||
## See also
|
||||
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML Namespace (x:) Language Features](/dotnet/desktop-wpf/xaml-services/namespace-language-features)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [XAML Namespace (x:) Language Features](/dotnet/desktop/xaml-services/namespace-language-features)
|
||||
- [WPF XAML Extensions](wpf-xaml-extensions.md)
|
||||
- [StaticResource Markup Extension](staticresource-markup-extension.md)
|
||||
- [Binding Markup Extension](binding-markup-extension.md)
|
||||
- [DynamicResource Markup Extension](dynamicresource-markup-extension.md)
|
||||
- [x:Type Markup Extension](/dotnet/desktop-wpf/xaml-services/xtype-markup-extension)
|
||||
- [x:Type Markup Extension](/dotnet/desktop/xaml-services/xtype-markup-extension)
|
||||
|
||||
@@ -63,5 +63,5 @@ Specifies which XML namespace prefixes encountered in a markup file may be ignor
|
||||
|
||||
- <xref:System.Windows.Markup.XamlReader>
|
||||
- [PresentationOptions:Freeze Attribute](presentationoptions-freeze-attribute.md)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Documents in WPF](documents-in-wpf.md)
|
||||
|
||||
@@ -45,4 +45,4 @@ Specifies which [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.
|
||||
## See also
|
||||
|
||||
- [mc:Ignorable Attribute](mc-ignorable-attribute.md)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
|
||||
@@ -14,7 +14,7 @@ ms.assetid: d159531f-05d4-49fd-b951-c332de51e5bc
|
||||
|
||||
[!code-xaml[ResourceMergeDictionary#MergedXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/ResourceMergeDictionary/CS/default.xaml#mergedxaml)]
|
||||
|
||||
Note that the <xref:System.Windows.ResourceDictionary> element does not have an [x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive), which is generally required for all items in a resource collection. But another <xref:System.Windows.ResourceDictionary> reference within the <xref:System.Windows.ResourceDictionary.MergedDictionaries%2A> collection is a special case, reserved for this merged resource dictionary scenario. The <xref:System.Windows.ResourceDictionary> that introduces a merged resource dictionary cannot have an [x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive). Typically, each <xref:System.Windows.ResourceDictionary> within the <xref:System.Windows.ResourceDictionary.MergedDictionaries%2A> collection specifies a <xref:System.Windows.ResourceDictionary.Source%2A> attribute. The value of <xref:System.Windows.ResourceDictionary.Source%2A> should be a uniform resource identifier (URI) that resolves to the location of the resources file to be merged. The destination of that URI must be another [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] file, with <xref:System.Windows.ResourceDictionary> as its root element.
|
||||
Note that the <xref:System.Windows.ResourceDictionary> element does not have an [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive), which is generally required for all items in a resource collection. But another <xref:System.Windows.ResourceDictionary> reference within the <xref:System.Windows.ResourceDictionary.MergedDictionaries%2A> collection is a special case, reserved for this merged resource dictionary scenario. The <xref:System.Windows.ResourceDictionary> that introduces a merged resource dictionary cannot have an [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive). Typically, each <xref:System.Windows.ResourceDictionary> within the <xref:System.Windows.ResourceDictionary.MergedDictionaries%2A> collection specifies a <xref:System.Windows.ResourceDictionary.Source%2A> attribute. The value of <xref:System.Windows.ResourceDictionary.Source%2A> should be a uniform resource identifier (URI) that resolves to the location of the resources file to be merged. The destination of that URI must be another [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] file, with <xref:System.Windows.ResourceDictionary> as its root element.
|
||||
|
||||
> [!NOTE]
|
||||
> It is legal to define resources within a <xref:System.Windows.ResourceDictionary> that is specified as a merged dictionary, either as an alternative to specifying <xref:System.Windows.ResourceDictionary.Source%2A>, or in addition to whatever resources are included from the specified source. However, this is not a common scenario; the main scenario for merged dictionaries is to merge resources from external file locations. If you want to specify resources within the markup for a page, you should typically define these in the main <xref:System.Windows.ResourceDictionary> and not in the merged dictionaries.
|
||||
|
||||
@@ -30,7 +30,7 @@ This topic describes the specific [!INCLUDE[TLA2#tla_winclient](../../../include
|
||||
|
||||
<a name="prerequisites"></a>
|
||||
## Prerequisites
|
||||
This topic assumes that you understand dependency properties from the perspective of a consumer of existing dependency properties on [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] classes, and have read the [Dependency Properties Overview](dependency-properties-overview.md) topic. In order to follow the examples in this topic, you should also understand [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] (see [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)) and know how to write [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications.
|
||||
This topic assumes that you understand dependency properties from the perspective of a consumer of existing dependency properties on [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] classes, and have read the [Dependency Properties Overview](dependency-properties-overview.md) topic. In order to follow the examples in this topic, you should also understand [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] (see [XAML in WPF](xaml-in-wpf.md)) and know how to write [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications.
|
||||
|
||||
<a name="intro"></a>
|
||||
## Object Lifetime Events
|
||||
|
||||
@@ -75,5 +75,5 @@ The following table lists the common controls for displaying data and their supp
|
||||
- [Layout and Design](optimizing-performance-layout-and-design.md)
|
||||
- [Data Binding](optimizing-performance-data-binding.md)
|
||||
- [Controls](../controls/index.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
- [Walkthrough: Caching Application Data in a WPF Application](walkthrough-caching-application-data-in-a-wpf-application.md)
|
||||
|
||||
@@ -76,5 +76,5 @@ ms.assetid: 1506a35d-c009-43db-9f1e-4e230ad5be73
|
||||
- [Application Resources](optimizing-performance-application-resources.md)
|
||||
- [Text](optimizing-performance-text.md)
|
||||
- [Other Performance Recommendations](optimizing-performance-other-recommendations.md)
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Walkthrough: Caching Application Data in a WPF Application](walkthrough-caching-application-data-in-a-wpf-application.md)
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ This section is intended as a reference for [!INCLUDE[TLA#tla_winclient](../../.
|
||||
- [Documents in WPF](documents-in-wpf.md)
|
||||
- [Drawing Formatted Text](drawing-formatted-text.md)
|
||||
- [Typography in WPF](typography-in-wpf.md)
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Navigation Overview](../app-development/navigation-overview.md)
|
||||
- [Animation Tips and Tricks](../graphics-multimedia/animation-tips-and-tricks.md)
|
||||
- [Walkthrough: Caching Application Data in a WPF Application](walkthrough-caching-application-data-in-a-wpf-application.md)
|
||||
|
||||
@@ -53,7 +53,7 @@ ms.assetid: 0a7989df-9674-4cc1-bc50-5d8ef5d9c055
|
||||
|
||||
Property triggers are generally appropriate for scenarios where one or more appearance properties should change, based on the state of another property on the same element.
|
||||
|
||||
To learn more about property triggers, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
To learn more about property triggers, see [Styling and Templating](../controls/styles-templates-overview.md).
|
||||
|
||||
## See also
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ For use as storyboard target, the property specified as `propertyName` must be a
|
||||
<object Path="propertyName/propertyNameX" ... />
|
||||
```
|
||||
|
||||
The / in this syntax is used to navigate within a hierarchical data source object, and multiple steps into the hierarchy with successive / characters are supported. The source traversal accounts for the current record pointer position, which is determined by synchronizing the data with the UI of its view. For details on binding with hierarchical data source objects, and the concept of current record pointer in data binding, see [Use the Master-Detail Pattern with Hierarchical Data](../data/how-to-use-the-master-detail-pattern-with-hierarchical-data.md) or [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
The / in this syntax is used to navigate within a hierarchical data source object, and multiple steps into the hierarchy with successive / characters are supported. The source traversal accounts for the current record pointer position, which is determined by synchronizing the data with the UI of its view. For details on binding with hierarchical data source objects, and the concept of current record pointer in data binding, see [Use the Master-Detail Pattern with Hierarchical Data](../data/how-to-use-the-master-detail-pattern-with-hierarchical-data.md) or [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
> [!NOTE]
|
||||
> Superficially, this syntax resembles XPath. A true XPath expression for binding to an XML data source is not used as a <xref:System.Windows.Data.Binding.Path%2A> value and should instead be used for the mutually exclusive <xref:System.Windows.Data.Binding.XPath%2A> property.
|
||||
@@ -186,7 +186,7 @@ In order to support cloning for animating a <xref:System.Windows.Freezable> that
|
||||
|
||||
`propertyName2` must be the name of a dependency property that exists on the object that is the value of `propertyName`. In other words, `propertyName2` must exist as a dependency property on the type that is the `propertyName` <xref:System.Windows.DependencyProperty.PropertyType%2A>.
|
||||
|
||||
Indirect targeting of animations is necessary because of applied styles and templates. In order to target an animation, you need a <xref:System.Windows.Media.Animation.Storyboard.TargetName%2A> on a target object, and that name is established by [x:Name](/dotnet/desktop-wpf/xaml-services/xname-directive) or <xref:System.Windows.FrameworkElement.Name%2A>. Although template and style elements also can have names, those names are only valid within the namescope of the style and template. (If templates and styles did share namescopes with application markup, names couldn't be unique. The styles and templates are literally shared between instances and would perpetuate duplicate names.) Thus, if the individual properties of an element that you might wish to animate came from a style or template, you need to start with a named element instance that is not from a style template, and then target into the style or template visual tree to arrive at the property you wish to animate.
|
||||
Indirect targeting of animations is necessary because of applied styles and templates. In order to target an animation, you need a <xref:System.Windows.Media.Animation.Storyboard.TargetName%2A> on a target object, and that name is established by [x:Name](/dotnet/desktop/xaml-services/xname-directive) or <xref:System.Windows.FrameworkElement.Name%2A>. Although template and style elements also can have names, those names are only valid within the namescope of the style and template. (If templates and styles did share namescopes with application markup, names couldn't be unique. The styles and templates are literally shared between instances and would perpetuate duplicate names.) Thus, if the individual properties of an element that you might wish to animate came from a style or template, you need to start with a named element instance that is not from a style template, and then target into the style or template visual tree to arrive at the property you wish to animate.
|
||||
|
||||
For instance, the <xref:System.Windows.Controls.Panel.Background%2A> property of a <xref:System.Windows.Controls.Panel> is a complete <xref:System.Windows.Media.Brush> (actually a <xref:System.Windows.Media.SolidColorBrush>) that came from a theme template. To animate a <xref:System.Windows.Media.Brush> completely, there would need to be a BrushAnimation (probably one for every <xref:System.Windows.Media.Brush> type) and there is no such type. To animate a Brush, you instead animate properties of a particular <xref:System.Windows.Media.Brush> type. You need to get from <xref:System.Windows.Media.SolidColorBrush> to its <xref:System.Windows.Media.SolidColorBrush.Color%2A> to apply a <xref:System.Windows.Media.Animation.ColorAnimation> there. The property path for this example would be `Background.Color`.
|
||||
|
||||
@@ -221,5 +221,5 @@ In general, <xref:System.Windows.PropertyPath> is designed to use two different
|
||||
## See also
|
||||
|
||||
- <xref:System.Windows.PropertyPath>
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Storyboards Overview](../graphics-multimedia/storyboards-overview.md)
|
||||
|
||||
@@ -39,4 +39,4 @@ This topic describes read-only dependency properties, including existing read-on
|
||||
|
||||
- [Dependency Properties Overview](dependency-properties-overview.md)
|
||||
- [Custom Dependency Properties](custom-dependency-properties.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
|
||||
@@ -65,7 +65,7 @@ Specifies properties of a <xref:System.Windows.Data.RelativeSource> binding sour
|
||||
|
||||
`{RelativeSource FindAncestor}` is mainly used in control templates or predictable self-contained UI compositions, for cases where a control is always expected to be in a visual tree of a certain ancestor type. For example, items of an items control might use `FindAncestor` usages to bind to properties of their items control parent ancestor. Or, elements that are part of control composition in a template can use `FindAncestor` bindings to the parent elements in that same composition structure.
|
||||
|
||||
In the object element syntax for `FindAncestor` mode shown in the XAML Syntax sections, the second object element syntax is used specifically for `FindAncestor` mode. `FindAncestor` mode requires an <xref:System.Windows.Data.RelativeSource.AncestorType%2A> value. You must set <xref:System.Windows.Data.RelativeSource.AncestorType%2A> as an attribute using an [x:Type Markup Extension](/dotnet/desktop-wpf/xaml-services/xtype-markup-extension) reference to the type of ancestor to look for. The <xref:System.Windows.Data.RelativeSource.AncestorType%2A> value is used when the binding request is processed at run-time.
|
||||
In the object element syntax for `FindAncestor` mode shown in the XAML Syntax sections, the second object element syntax is used specifically for `FindAncestor` mode. `FindAncestor` mode requires an <xref:System.Windows.Data.RelativeSource.AncestorType%2A> value. You must set <xref:System.Windows.Data.RelativeSource.AncestorType%2A> as an attribute using an [x:Type Markup Extension](/dotnet/desktop/xaml-services/xtype-markup-extension) reference to the type of ancestor to look for. The <xref:System.Windows.Data.RelativeSource.AncestorType%2A> value is used when the binding request is processed at run-time.
|
||||
|
||||
For `FindAncestor` mode, the optional property <xref:System.Windows.Data.RelativeSource.AncestorLevel%2A> can help disambiguate the ancestor lookup in cases where there is possibly more than one ancestor of that type existing in the element tree.
|
||||
|
||||
@@ -100,7 +100,7 @@ In the following example, the first <xref:System.Windows.Controls.TextBlock> in
|
||||
</ListBox>
|
||||
```
|
||||
|
||||
Describing data binding as a concept is not covered here, see [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
Describing data binding as a concept is not covered here, see [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
In the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] XAML processor implementation, the handling for this markup extension is defined by the <xref:System.Windows.Data.RelativeSource> class.
|
||||
|
||||
@@ -109,9 +109,9 @@ In the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md
|
||||
## See also
|
||||
|
||||
- <xref:System.Windows.Data.Binding>
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md)
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Binding Declarations Overview](../data/binding-declarations-overview.md)
|
||||
- [x:Type Markup Extension](/dotnet/desktop-wpf/xaml-services/xtype-markup-extension)
|
||||
- [x:Type Markup Extension](/dotnet/desktop/xaml-services/xtype-markup-extension)
|
||||
|
||||
@@ -36,9 +36,9 @@ This overview concentrates on how [!INCLUDE[TLA#tla_winclient](../../../includes
|
||||
|
||||
<a name="objectaskey"></a>
|
||||
## Using Objects as Keys
|
||||
Most resource usages will set the key of the resource to be a string. However, various [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] features deliberately do not use a string type to specify keys, instead this parameter is an object. The capability of having the resource be keyed by an object is used by the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] style and theming support. The styles in themes which become the default style for an otherwise non-styled control are each keyed by the <xref:System.Type> of the control that they should apply to. Being keyed by type provides a reliable lookup mechanism that works on default instances of each control type, and type can be detected by reflection and used for styling derived classes even though the derived type otherwise has no default style. You can specify a <xref:System.Type> key for a resource defined in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] by using the [x:Type Markup Extension](/dotnet/desktop-wpf/xaml-services/xtype-markup-extension). Similar extensions exist for other nonstring key usages that support [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] features, such as [ComponentResourceKey Markup Extension](componentresourcekey-markup-extension.md).
|
||||
Most resource usages will set the key of the resource to be a string. However, various [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] features deliberately do not use a string type to specify keys, instead this parameter is an object. The capability of having the resource be keyed by an object is used by the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] style and theming support. The styles in themes which become the default style for an otherwise non-styled control are each keyed by the <xref:System.Type> of the control that they should apply to. Being keyed by type provides a reliable lookup mechanism that works on default instances of each control type, and type can be detected by reflection and used for styling derived classes even though the derived type otherwise has no default style. You can specify a <xref:System.Type> key for a resource defined in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] by using the [x:Type Markup Extension](/dotnet/desktop/xaml-services/xtype-markup-extension). Similar extensions exist for other nonstring key usages that support [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] features, such as [ComponentResourceKey Markup Extension](componentresourcekey-markup-extension.md).
|
||||
|
||||
## See also
|
||||
|
||||
- [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
|
||||
@@ -24,7 +24,7 @@ A resource is an object that can be reused in different places in your applicati
|
||||
|
||||
[DynamicResource Markup Extension](dynamicresource-markup-extension.md)
|
||||
|
||||
[x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive)
|
||||
[x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive)
|
||||
|
||||
## Related Sections
|
||||
[XAML in WPF](xaml-in-wpf.md)
|
||||
|
||||
@@ -26,7 +26,7 @@ This topic describes the concept of routed events in [!INCLUDE[TLA#tla_winclient
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This topic assumes that you have basic knowledge of the common language runtime (CLR) and object-oriented programming, as well as the concept of how the relationships between [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] elements can be conceptualized as a tree. In order to follow the examples in this topic, you should also understand [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] and know how to write very basic [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications or pages. For more information, see [Walkthrough: My first WPF desktop application](../getting-started/walkthrough-my-first-wpf-desktop-application.md) and [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml).
|
||||
This topic assumes that you have basic knowledge of the common language runtime (CLR) and object-oriented programming, as well as the concept of how the relationships between [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] elements can be conceptualized as a tree. In order to follow the examples in this topic, you should also understand [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] and know how to write very basic [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications or pages. For more information, see [Walkthrough: My first WPF desktop application](../getting-started/walkthrough-my-first-wpf-desktop-application.md) and [XAML in WPF](xaml-in-wpf.md).
|
||||
|
||||
<a name="routing"></a>
|
||||
|
||||
@@ -84,7 +84,7 @@ To add a handler for an event using [!INCLUDE[TLA2#tla_xaml](../../../includes/t
|
||||
|
||||
[!code-xaml[EventOvwSupport#SimplestSyntax](~/samples/snippets/csharp/VS_Snippets_Wpf/EventOvwSupport/CSharp/default.xaml#simplestsyntax)]
|
||||
|
||||
The [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] syntax for adding standard CLR event handlers is the same for adding routed event handlers, because you are really adding handlers to the CLR event wrapper, which has a routed event implementation underneath. For more information about adding event handlers in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)], see [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml).
|
||||
The [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] syntax for adding standard CLR event handlers is the same for adding routed event handlers, because you are really adding handlers to the CLR event wrapper, which has a routed event implementation underneath. For more information about adding event handlers in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)], see [XAML in WPF](xaml-in-wpf.md).
|
||||
|
||||
<a name="routing_strategies"></a>
|
||||
|
||||
|
||||
@@ -33,16 +33,16 @@ Provides a value for any [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla
|
||||
|
||||
|||
|
||||
|-|-|
|
||||
|`key`|The key for the requested resource. This key was initially assigned by the [x:Key Directive](/dotnet/desktop-wpf/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
|
||||
|
||||
> [!IMPORTANT]
|
||||
> A `StaticResource` must not attempt to make a forward reference to a resource that is defined lexically further within the [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] file. Attempting to do so is not supported, and even if such a reference does not fail, attempting the forward reference will incur a load time performance penalty when the internal hash tables representing a <xref:System.Windows.ResourceDictionary> are searched. For best results, adjust the composition of your resource dictionaries such that forward references can be avoided. If you cannot avoid a forward reference, use [DynamicResource Markup Extension](dynamicresource-markup-extension.md) instead.
|
||||
|
||||
The specified <xref:System.Windows.StaticResourceExtension.ResourceKey%2A> should correspond to an existing resource, identified with an [x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive) at some level in your page, application, the available control themes and external resources, or system resources. The resource lookup occurs in that order. For more information about resource lookup behavior for static and dynamic resources, see [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define).
|
||||
The specified <xref:System.Windows.StaticResourceExtension.ResourceKey%2A> should correspond to an existing resource, identified with an [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive) at some level in your page, application, the available control themes and external resources, or system resources. The resource lookup occurs in that order. For more information about resource lookup behavior for static and dynamic resources, see [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define).
|
||||
|
||||
A resource key can be any string defined in the [XamlName Grammar](/dotnet/desktop-wpf/xaml-services/xamlname-grammar). A resource key can also be other object types, such as a <xref:System.Type>. A <xref:System.Type> key is fundamental to how controls can be styled by themes, through an implicit style key. For more information, see [Control Authoring Overview](../controls/control-authoring-overview.md).
|
||||
A resource key can be any string defined in the [XamlName Grammar](/dotnet/desktop/xaml-services/xamlname-grammar). A resource key can also be other object types, such as a <xref:System.Type>. A <xref:System.Type> key is fundamental to how controls can be styled by themes, through an implicit style key. For more information, see [Control Authoring Overview](../controls/control-authoring-overview.md).
|
||||
|
||||
The alternative declarative means of referencing a resource is as a [DynamicResource Markup Extension](dynamicresource-markup-extension.md).
|
||||
|
||||
@@ -64,8 +64,8 @@ Provides a value for any [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla
|
||||
|
||||
## See also
|
||||
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md)
|
||||
- [XAML Resources](/dotnet/desktop-wpf/fundamentals/xaml-resources-define)
|
||||
- [Resources and Code](resources-and-code.md)
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ ms.assetid: 786ac576-011b-4d72-913b-558deccb9b35
|
||||
## Alternatives to Using a Focus Visual Style
|
||||
For situations where using a focus visual style is not appropriate, either because you are only styling single controls or because you want greater control over the control template, there are many other accessible properties and techniques that can create visual behavior in response to changes in focus.
|
||||
|
||||
Triggers, setters, and event setters are all discussed in detail in [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview). Routed event handling is discussed in [Routed Events Overview](routed-events-overview.md).
|
||||
Triggers, setters, and event setters are all discussed in detail in [Styling and Templating](../controls/styles-templates-overview.md). Routed event handling is discussed in [Routed Events Overview](routed-events-overview.md).
|
||||
|
||||
### IsKeyboardFocused
|
||||
If you are specifically interested in keyboard focus, the <xref:System.Windows.UIElement.IsKeyboardFocused%2A> dependency property can be used for a property <xref:System.Windows.Trigger>. A property trigger in either a style or template is a more appropriate technique for defining a keyboard focus behavior that is very specifically for a single control, and which might not visually match the keyboard focus behavior for other controls.
|
||||
@@ -72,6 +72,6 @@ ms.assetid: 786ac576-011b-4d72-913b-558deccb9b35
|
||||
## See also
|
||||
|
||||
- <xref:System.Windows.FrameworkElement.FocusVisualStyle%2A>
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
- [Focus Overview](focus-overview.md)
|
||||
- [Input Overview](input-overview.md)
|
||||
|
||||
@@ -59,8 +59,8 @@ Links the value of a property in a control template to be the value of another p
|
||||
|
||||
- <xref:System.Windows.Style>
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md)
|
||||
- [RelativeSource MarkupExtension](relativesource-markupextension.md)
|
||||
- [Binding Markup Extension](binding-markup-extension.md)
|
||||
|
||||
@@ -59,7 +59,7 @@ Provides a way for custom control authors or applications that integrate third-p
|
||||
|
||||
## See also
|
||||
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [Styling and Templating](../controls/styles-templates-overview.md)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md)
|
||||
- [WPF Application Resource, Content, and Data Files](../app-development/wpf-application-resource-content-and-data-files.md)
|
||||
|
||||
@@ -37,7 +37,7 @@ In many technologies, elements and components are organized in a tree structure
|
||||
|
||||
However, the logical tree is not the entire object graph that exists for your application UI at run time, even with the XAML implicit syntax items factored out. The main reason for this is visuals and templates. For example, consider the <xref:System.Windows.Controls.Button>. The logical tree reports the <xref:System.Windows.Controls.Button> object and also its string `Content`. But there is more to this button in the run-time object tree. In particular, the button only appears on screen the way it does because a specific <xref:System.Windows.Controls.Button> control template was applied. The visuals that come from an applied template (such as the template-defined <xref:System.Windows.Controls.Border> of dark gray around the visual button) are not reported in the logical tree, even if you are looking at the logical tree during run time (such as handling an input event from the visible UI and then reading the logical tree). To find the template visuals, you would instead need to examine the visual tree.
|
||||
|
||||
For more information about how [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] syntax maps to the created object graph, and implicit syntax in XAML, see [XAML Syntax In Detail](xaml-syntax-in-detail.md) or [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml).
|
||||
For more information about how [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] syntax maps to the created object graph, and implicit syntax in XAML, see [XAML Syntax In Detail](xaml-syntax-in-detail.md) or [XAML in WPF](xaml-in-wpf.md).
|
||||
|
||||
<a name="tree_property_inheritance_event_routing"></a>
|
||||
|
||||
|
||||
@@ -105,6 +105,6 @@ This topic introduces the purpose of type conversion from string as a general XA
|
||||
## See also
|
||||
|
||||
- <xref:System.ComponentModel.TypeConverter>
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md)
|
||||
- [XAML Syntax In Detail](xaml-syntax-in-detail.md)
|
||||
|
||||
@@ -62,7 +62,7 @@ The following table contains a list of the XAML feature-support classes that are
|
||||
|<xref:System.Windows.Markup.StaticExtension>|`{x:Static ...}`|
|
||||
|<xref:System.Windows.Markup.TypeExtension>|`{x:Type ...}`|
|
||||
|
||||
Although System.Xaml may not have specific support classes, the general logic for processing language features for the XAML language now resides in System.Xaml and its implemented XAML readers and XAML writers. For example, `x:TypeArguments` is an attribute that is processed by XAML readers and XAML writers from System.Xaml implementations; it can be noted in the XAML node stream, has handling in the default (CLR-based) XAML schema context, has a XAML type-system representation, and so on. As a result, the reference documentation for all XAML language-level features is a subtopic for [XAML Services](/dotnet/desktop-wpf/xaml-services/index) in the [Desktop Guide for Windows Presentation Foundation (WPF)](/dotnet/desktop-wpf/overview/index).
|
||||
Although System.Xaml may not have specific support classes, the general logic for processing language features for the XAML language now resides in System.Xaml and its implemented XAML readers and XAML writers. For example, `x:TypeArguments` is an attribute that is processed by XAML readers and XAML writers from System.Xaml implementations; it can be noted in the XAML node stream, has handling in the default (CLR-based) XAML schema context, has a XAML type-system representation, and so on. For more information about the reference documentation for XAML, see [XAML Services](/dotnet/desktop/xaml-services/index).
|
||||
|
||||
## ValueSerializer and Supporting Classes
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ ms.assetid: ad4eb9aa-3afc-4a71-8cf6-add3fbea54a1
|
||||
For the Microsoft Visual Basic .NET language specifically, you can use the language-specific `Handles` keyword to associate event handlers with instances, instead of attaching event handlers with attributes or using the <xref:System.Windows.UIElement.AddHandler%2A> method. However, the `Handles` technique for attaching handlers to instances does have some limitations, because the `Handles` syntax cannot support some of the specific routed event features of the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] event system.
|
||||
|
||||
## Using "Handles" in a WPF Application
|
||||
The event handlers that are connected to instances and events with `Handles` must all be defined within the partial class declaration of the instance, which is also a requirement for event handlers that are assigned through attribute values on elements. You can only specify `Handles` for an element on the page that has a <xref:System.Windows.FrameworkContentElement.Name%2A> property value (or [x:Name Directive](/dotnet/desktop-wpf/xaml-services/xname-directive) declared). This is because the <xref:System.Windows.FrameworkContentElement.Name%2A> in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] creates the instance reference that is necessary to support the *Instance.Event* reference format required by the `Handles` syntax. The only element that can be used for `Handles` without a <xref:System.Windows.FrameworkContentElement.Name%2A> reference is the root-element instance that defines the partial class.
|
||||
The event handlers that are connected to instances and events with `Handles` must all be defined within the partial class declaration of the instance, which is also a requirement for event handlers that are assigned through attribute values on elements. You can only specify `Handles` for an element on the page that has a <xref:System.Windows.FrameworkContentElement.Name%2A> property value (or [x:Name Directive](/dotnet/desktop/xaml-services/xname-directive) declared). This is because the <xref:System.Windows.FrameworkContentElement.Name%2A> in [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] creates the instance reference that is necessary to support the *Instance.Event* reference format required by the `Handles` syntax. The only element that can be used for `Handles` without a <xref:System.Windows.FrameworkContentElement.Name%2A> reference is the root-element instance that defines the partial class.
|
||||
|
||||
You can assign the same handler to multiple elements by separating *Instance.Event* references after `Handles` with commas.
|
||||
|
||||
@@ -31,7 +31,7 @@ For the Microsoft Visual Basic .NET language specifically, you can use the langu
|
||||
> Do not use the `Handles` syntax in Visual Basic code when you specify an event handler for the same event in XAML. In this case, the event handler is called twice.
|
||||
|
||||
## How WPF Implements "Handles" Functionality
|
||||
When a [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] page is compiled, the intermediate file declares `Friend` `WithEvents` references to every element on the page that has a <xref:System.Windows.FrameworkContentElement.Name%2A> property set (or [x:Name Directive](/dotnet/desktop-wpf/xaml-services/xname-directive) declared). Each named instance is potentially an element that can be assigned to a handler through `Handles`.
|
||||
When a [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] page is compiled, the intermediate file declares `Friend` `WithEvents` references to every element on the page that has a <xref:System.Windows.FrameworkContentElement.Name%2A> property set (or [x:Name Directive](/dotnet/desktop/xaml-services/xname-directive) declared). Each named instance is potentially an element that can be assigned to a handler through `Handles`.
|
||||
|
||||
> [!NOTE]
|
||||
> Within Visual Studio, IntelliSense can show you completion for which elements are available for a `Handles` reference in a page. However, this might take one compile pass so that the intermediate file can populate all the `Friends` references.
|
||||
@@ -41,4 +41,4 @@ For the Microsoft Visual Basic .NET language specifically, you can use the langu
|
||||
- <xref:System.Windows.UIElement.AddHandler%2A>
|
||||
- [Marking Routed Events as Handled, and Class Handling](marking-routed-events-as-handled-and-class-handling.md)
|
||||
- [Routed Events Overview](routed-events-overview.md)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ You need Visual Studio to complete this walkthrough.
|
||||
#### Styling the UI Elements
|
||||
Many of the elements on the data-entry form have a similar appearance, which means that they have identical settings for several of their properties. Rather than setting each element's attributes separately, the previous XAML uses <xref:System.Windows.Style> elements to define standard property settings for classes of elements. This approach reduces the complexity of the control and enables you to change the appearance of multiple elements through a single style attribute.
|
||||
|
||||
The <xref:System.Windows.Style> elements are contained in the <xref:System.Windows.Controls.Grid> element's <xref:System.Windows.FrameworkElement.Resources%2A> property, so they can be used by all elements in the control. If a style is named, you apply it to an element by adding a <xref:System.Windows.Style> element set to the style's name. Styles that are not named become the default style for the element. For more information about [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] styles, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
The <xref:System.Windows.Style> elements are contained in the <xref:System.Windows.Controls.Grid> element's <xref:System.Windows.FrameworkElement.Resources%2A> property, so they can be used by all elements in the control. If a style is named, you apply it to an element by adding a <xref:System.Windows.Style> element set to the style's name. Styles that are not named become the default style for the element. For more information about [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] styles, see [Styling and Templating](../controls/styles-templates-overview.md).
|
||||
|
||||
The following XAML shows the <xref:System.Windows.Style> elements for the composite control. To see how the styles are applied to elements, see the previous XAML. For example, the last <xref:System.Windows.Controls.TextBlock> element has the `inlineText` style, and the last <xref:System.Windows.Controls.TextBox> element uses the default style.
|
||||
|
||||
|
||||
@@ -130,4 +130,4 @@ In applications, it is possible that handlers that are attached to event sources
|
||||
- <xref:System.Windows.WeakEventManager>
|
||||
- <xref:System.Windows.IWeakEventListener>
|
||||
- [Routed Events Overview](routed-events-overview.md)
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
|
||||
@@ -145,6 +145,6 @@ This topic provides a guided tour of the Windows Presentation Foundation (WPF) c
|
||||
- <xref:System.Windows.Threading.DispatcherObject>
|
||||
- <xref:System.Windows.Input.CommandBinding>
|
||||
- <xref:System.Windows.Controls.Control>
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Layout](layout.md)
|
||||
- [Animation Overview](../graphics-multimedia/animation-overview.md)
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ When you design a [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-w
|
||||
|
||||
- Enable <xref:System.Windows.Controls.TextBlock.TextWrapping%2A> on <xref:System.Windows.Controls.TextBlock> to avoid clipping.
|
||||
|
||||
- Set the `xml:lang` attribute. This attribute describes the culture of a specific element and its child elements. The value of this property changes the behavior of several features in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]. For example, it changes the behavior of hyphenation, spell checking, number substitution, complex script shaping, and font fallback. See [Globalization for WPF](globalization-for-wpf.md) for more information about setting the [xml:lang Handling in XAML](/dotnet/desktop-wpf/xaml-services/xml-language-handling).
|
||||
- Set the `xml:lang` attribute. This attribute describes the culture of a specific element and its child elements. The value of this property changes the behavior of several features in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]. For example, it changes the behavior of hyphenation, spell checking, number substitution, complex script shaping, and font fallback. See [Globalization for WPF](globalization-for-wpf.md) for more information about setting the [xml:lang Handling in XAML](/dotnet/desktop/xaml-services/xml-language-handling).
|
||||
|
||||
- Create a customized composite font to obtain better control of fonts that are used for different languages. By default, [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] uses the GlobalUserInterface.composite font in your Windows\Fonts directory.
|
||||
|
||||
@@ -144,7 +144,7 @@ Note that of the example uses the shared-sizing feature of <xref:System.Windows.
|
||||
|
||||
`xml:lang="en-US"`
|
||||
|
||||
Notice the [xml:lang Handling in XAML](/dotnet/desktop-wpf/xaml-services/xml-language-handling) placed at the root element of the [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)]. This property describes the culture of a given element and its children. This value is used by several features in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] and should be changed appropriately during localization. This value changes what language dictionary is use to hyphenate and spell check words. It also affects the display of digits and how the font fallback system selects which font to use. Finally, the property affects the way numbers are displayed and the way texts written in complex scripts are shaped. The default value is "en-US".
|
||||
Notice the [xml:lang Handling in XAML](/dotnet/desktop/xaml-services/xml-language-handling) placed at the root element of the [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)]. This property describes the culture of a given element and its children. This value is used by several features in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] and should be changed appropriately during localization. This value changes what language dictionary is use to hyphenate and spell check words. It also affects the display of digits and how the font fallback system selects which font to use. Finally, the property affects the way numbers are displayed and the way texts written in complex scripts are shaped. The default value is "en-US".
|
||||
|
||||
**Building a Satellite Resource Assembly**
|
||||
|
||||
|
||||
@@ -91,4 +91,4 @@ XAML namescopes are a concept that identifies objects that are defined in XAML.
|
||||
## See also
|
||||
|
||||
- [XAML Namespaces and Namespace Mapping for WPF XAML](xaml-namespaces-and-namespace-mapping-for-wpf-xaml.md)
|
||||
- [x:Name Directive](/dotnet/desktop-wpf/xaml-services/xname-directive)
|
||||
- [x:Name Directive](/dotnet/desktop/xaml-services/xname-directive)
|
||||
|
||||
@@ -71,7 +71,7 @@ XAML as implemented in common language runtime (CLR) frameworks supports the abi
|
||||
|
||||
- The object that is the collection object does not need to be specified in object element syntax. The presence of that collection type is implicit whenever you specify a property in XAML that takes a collection type.
|
||||
|
||||
- Child elements of the collection property in markup are processed to become members of the collection. Ordinarily, the code access to the members of a collection is performed through list/dictionary methods such as `Add`, or through an indexer. But XAML syntax does not support methods or indexers (exception: XAML 2009 can support methods, but using XAML 2009 restricts the possible WPF usages; see [XAML 2009 Language Features](/dotnet/desktop-wpf/xaml-services/xaml-2009-language-features)). Collections are obviously a very common requirement for building a tree of elements, and you need some way to populate these collections in declarative XAML. Therefore, child elements of a collection property are processed by adding them to the collection that is the collection property type value.
|
||||
- Child elements of the collection property in markup are processed to become members of the collection. Ordinarily, the code access to the members of a collection is performed through list/dictionary methods such as `Add`, or through an indexer. But XAML syntax does not support methods or indexers (exception: XAML 2009 can support methods, but using XAML 2009 restricts the possible WPF usages; see [XAML 2009 Language Features](/dotnet/desktop/xaml-services/xaml-2009-language-features)). Collections are obviously a very common requirement for building a tree of elements, and you need some way to populate these collections in declarative XAML. Therefore, child elements of a collection property are processed by adding them to the collection that is the collection property type value.
|
||||
|
||||
The .NET Framework XAML Services implementation and thus the WPF XAML processor uses the following definition for what constitutes a collection property. The property type of the property must implement one of the following:
|
||||
|
||||
@@ -79,7 +79,7 @@ XAML as implemented in common language runtime (CLR) frameworks supports the abi
|
||||
|
||||
- Implements <xref:System.Collections.IDictionary> or the generic equivalent (<xref:System.Collections.Generic.IDictionary%602>).
|
||||
|
||||
- Derives from <xref:System.Array> (for more information about arrays in XAML, see [x:Array Markup Extension](/dotnet/desktop-wpf/xaml-services/xarray-markup-extension).)
|
||||
- Derives from <xref:System.Array> (for more information about arrays in XAML, see [x:Array Markup Extension](/dotnet/desktop/xaml-services/xarray-markup-extension).)
|
||||
|
||||
- Implements <xref:System.Windows.Markup.IAddChild> (an interface defined by [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]).
|
||||
|
||||
@@ -106,7 +106,7 @@ XAML as implemented in common language runtime (CLR) frameworks supports the abi
|
||||
|
||||
## See also
|
||||
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Custom Dependency Properties](custom-dependency-properties.md)
|
||||
- [Control Authoring Overview](../controls/control-authoring-overview.md)
|
||||
- [Base Elements Overview](base-elements-overview.md)
|
||||
|
||||
@@ -14,7 +14,7 @@ ms.assetid: 5d858575-a83b-42df-ad3f-047ed2d6e3c8
|
||||
|
||||
## In This Section
|
||||
|
||||
[XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
[XAML in WPF](xaml-in-wpf.md)
|
||||
[XAML Syntax In Detail](xaml-syntax-in-detail.md)
|
||||
[Code-Behind and XAML in WPF](code-behind-and-xaml-in-wpf.md)
|
||||
[XAML and Custom Classes for WPF](xaml-and-custom-classes-for-wpf.md)
|
||||
@@ -22,10 +22,10 @@ ms.assetid: 5d858575-a83b-42df-ad3f-047ed2d6e3c8
|
||||
[XAML Namespaces and Namespace Mapping for WPF XAML](xaml-namespaces-and-namespace-mapping-for-wpf-xaml.md)
|
||||
[WPF XAML Namescopes](wpf-xaml-namescopes.md)
|
||||
[Inline Styles and Templates](inline-styles-and-templates.md)
|
||||
[White-space Processing in XAML](/dotnet/desktop-wpf/xaml-services/white-space-processing)
|
||||
[White-space Processing in XAML](/dotnet/desktop/xaml-services/white-space-processing)
|
||||
[TypeConverters and XAML](typeconverters-and-xaml.md)
|
||||
[XML Character Entities and XAML](/dotnet/desktop-wpf/xaml-services/xml-character-entities)
|
||||
[XAML Namespace (x:) Language Features](/dotnet/desktop-wpf/xaml-services/namespace-language-features)
|
||||
[XML Character Entities and XAML](/dotnet/desktop/xaml-services/xml-character-entities)
|
||||
[XAML Namespace (x:) Language Features](/dotnet/desktop/xaml-services/namespace-language-features)
|
||||
[WPF XAML Extensions](wpf-xaml-extensions.md)
|
||||
[Markup Compatibility (mc:) Language Features](markup-compatibility-mc-language-features.md)
|
||||
|
||||
@@ -38,5 +38,5 @@ ms.assetid: 5d858575-a83b-42df-ad3f-047ed2d6e3c8
|
||||
[Events](events-wpf.md)
|
||||
[Input](input-wpf.md)
|
||||
[Resources](resources-wpf.md)
|
||||
[Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
[Styling and Templating](../controls/styles-templates-overview.md)
|
||||
[Threading Model](threading-model.md)
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ The current [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclie
|
||||
|
||||
<a name="prerequisites"></a>
|
||||
## Prerequisites
|
||||
This topic assumes that you understand dependency properties both as consumer and author and have read [Dependency Properties Overview](dependency-properties-overview.md) and [Custom Dependency Properties](custom-dependency-properties.md). You should also have read [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml) and [XAML Syntax In Detail](xaml-syntax-in-detail.md).
|
||||
This topic assumes that you understand dependency properties both as consumer and author and have read [Dependency Properties Overview](dependency-properties-overview.md) and [Custom Dependency Properties](custom-dependency-properties.md). You should also have read [XAML in WPF](xaml-in-wpf.md) and [XAML Syntax In Detail](xaml-syntax-in-detail.md).
|
||||
|
||||
<a name="implementation"></a>
|
||||
## The WPF XAML Loader Implementation, and Performance
|
||||
@@ -37,7 +37,7 @@ The current [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclie
|
||||
## See also
|
||||
|
||||
- [Dependency Properties Overview](dependency-properties-overview.md)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [Dependency Property Metadata](dependency-property-metadata.md)
|
||||
- [Collection-Type Dependency Properties](collection-type-dependency-properties.md)
|
||||
- [Dependency Property Security](dependency-property-security.md)
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ This topic further explains the presence and purpose of the two XAML namespace m
|
||||
|
||||
The relationship between these declarations is that the `x:` prefix mapping supports the intrinsics that are part of the XAML language definition, and [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] is one implementation that uses XAML as a language and defines a vocabulary of its objects for XAML. Because the WPF vocabulary's usages will be far more common than the XAML intrinsics usages, the WPF vocabulary is mapped as the default.
|
||||
|
||||
The `x:` prefix convention for mapping the XAML language intrinsics support is followed by project templates, sample code, and the documentation of language features within this SDK. The XAML namespace defines many commonly-used features that are necessary even for basic WPF applications. For instance, in order to join any code-behind to a XAML file through a partial class, you must name that class as the `x:Class` attribute in the root element of the relevant XAML file. Or, any element as defined in a XAML page that you wish to access as a keyed resource should have the `x:Key` attribute set on the element in question. For more information on these and other aspects of XAML see [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml) or [XAML Syntax In Detail](xaml-syntax-in-detail.md).
|
||||
The `x:` prefix convention for mapping the XAML language intrinsics support is followed by project templates, sample code, and the documentation of language features within this SDK. The XAML namespace defines many commonly-used features that are necessary even for basic WPF applications. For instance, in order to join any code-behind to a XAML file through a partial class, you must name that class as the `x:Class` attribute in the root element of the relevant XAML file. Or, any element as defined in a XAML page that you wish to access as a keyed resource should have the `x:Key` attribute set on the element in question. For more information on these and other aspects of XAML see [XAML in WPF](xaml-in-wpf.md) or [XAML Syntax In Detail](xaml-syntax-in-detail.md).
|
||||
|
||||
<a name="Mapping_To_Custom_Classes_and_Assemblies"></a>
|
||||
|
||||
@@ -145,4 +145,4 @@ End Namespace
|
||||
## See also
|
||||
|
||||
- [Understanding XML Namespaces](/previous-versions/aa468565(v=msdn.10))
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
|
||||
@@ -33,6 +33,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 67cce290-ca26-4c41-a797-b68aabc45479
|
||||
---
|
||||
# XAML Syntax In Detail
|
||||
This topic defines the terms that are used to describe the elements of XAML syntax. These terms are used frequently throughout the remainder of this documentation, both for WPF documentation specifically and for the other frameworks that use XAML or the basic XAML concepts enabled by the XAML language support at the System.Xaml level. This topic expands on the basic terminology introduced in the topic [XAML in WPF](xaml-in-wpf.md).
|
||||
|
||||
This topic defines the terms that are used to describe the elements of XAML syntax. These terms are used frequently throughout the remainder of this documentation, both for WPF documentation specifically and for the other frameworks that use XAML or the basic XAML concepts enabled by the XAML language support at the System.Xaml level. This topic expands on the basic terminology introduced in the topic [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml).
|
||||
|
||||
@@ -85,91 +86,88 @@ By setting values of properties, you add features or characteristics to objects
|
||||
Attribute syntax is the XAML markup syntax that sets a value for a property by declaring an attribute on an existing object element. The attribute name must match the CLR member name of the property of the class that backs the relevant object element. The attribute name is followed by an assignment operator (=). The attribute value must be a string enclosed within quotes.
|
||||
|
||||
> [!NOTE]
|
||||
> You can use alternating quotes to place a literal quotation mark within an attribute. For instance you can use single quotes as a means to declare a string that contains a double quote character within it. Whether you use single or double quotes, you should use a matching pair for opening and closing the attribute value string. There are also escape sequences or other techniques available for working around character restrictions imposed by any particular XAML syntax. See [XML Character Entities and XAML](/dotnet/desktop-wpf/xaml-services/xml-character-entities).
|
||||
|
||||
In order to be set through attribute syntax, a property must be public and must be writeable. The value of the property in the backing type system must be a value type, or must be a reference type that can be instantiated or referenced by a XAML processor when accessing the relevant backing type.
|
||||
|
||||
For WPF XAML events, the event that is referenced as the attribute name must be public and have a public delegate.
|
||||
|
||||
The property or event must be a member of the class or structure that is instantiated by the containing object element.
|
||||
|
||||
### Processing of Attribute Values
|
||||
|
||||
The string value contained within the opening and closing quotation marks is processed by a XAML processor. For properties, the default processing behavior is determined by the type of the underlying CLR property.
|
||||
|
||||
The attribute value is filled by one of the following, using this processing order:
|
||||
|
||||
1. If the XAML processor encounters a curly brace, or an object element that derives from <xref:System.Windows.Markup.MarkupExtension>, then the referenced markup extension is evaluated first rather than processing the value as a string, and the object returned by the markup extension is used as the value. In many cases the object returned by a markup extension will be a reference to an existing object, or an expression that defers evaluation until run time, and is not a newly instantiated object.
|
||||
|
||||
2. If the property is declared with an attributed <xref:System.ComponentModel.TypeConverter>, or the value type of that property is declared with an attributed <xref:System.ComponentModel.TypeConverter>, the string value of the attribute is submitted to the type converter as a conversion input, and the converter will return a new object instance.
|
||||
|
||||
3. If there is no <xref:System.ComponentModel.TypeConverter>, a direct conversion to the property type is attempted. This final level is a direct conversion at the parser-native value between XAML language primitive types, or a check for the names of named constants in an enumeration (the parser then accesses the matching values).
|
||||
|
||||
#### Enumeration Attribute Values
|
||||
|
||||
Enumerations in XAML are processed intrinsically by XAML parsers, and the members of an enumeration should be specified by specifying the string name of one of the enumeration's named constants.
|
||||
|
||||
For nonflag enumeration values, the native behavior is to process the string of an attribute value and resolve it to one of the enumeration values. You do not specify the enumeration in the format *Enumeration*.*Value*, as you do in code. Instead, you specify only *Value*, and *Enumeration* is inferred by the type of the property you are setting. If you specify an attribute in the *Enumeration*.*Value* form, it will not resolve correctly.
|
||||
|
||||
For flagwise enumerations, the behavior is based on the <xref:System.Enum.Parse%2A?displayProperty=nameWithType> method. You can specify multiple values for a flagwise enumeration by separating each value with a comma. However, you cannot combine enumeration values that are not flagwise. For instance, you cannot use the comma syntax to attempt to create a <xref:System.Windows.Trigger> that acts on multiple conditions of a nonflag enumeration:
|
||||
|
||||
```xaml
|
||||
<!--This will not compile, because Visibility is not a flagwise enumeration.-->
|
||||
...
|
||||
<Trigger Property="Visibility" Value="Collapsed,Hidden">
|
||||
<Setter ... />
|
||||
</Trigger>
|
||||
...
|
||||
```
|
||||
|
||||
Flagwise enumerations that support attributes that are settable in XAML are rare in WPF. However, one such enumeration is <xref:System.Windows.Media.StyleSimulations>. You could, for instance, use the comma-delimited flagwise attribute syntax to modify the example provided in the Remarks for the <xref:System.Windows.Documents.Glyphs> class; `StyleSimulations = "BoldSimulation"` could become `StyleSimulations = "BoldSimulation,ItalicSimulation"`. <xref:System.Windows.Input.KeyBinding.Modifiers%2A?displayProperty=nameWithType> is another property where more than one enumeration value can be specified. However, this property happens to be a special case, because the <xref:System.Windows.Input.ModifierKeys> enumeration supports its own type converter. The type converter for modifiers uses a plus sign (+) as a delimiter rather than a comma (,). This conversion supports the more traditional syntax to represent key combinations in Microsoft Windows programming, such as "Ctrl+Alt".
|
||||
|
||||
### Properties and Event Member Name References
|
||||
|
||||
When specifying an attribute, you can reference any property or event that exists as a member of the CLR type you instantiated for the containing object element.
|
||||
|
||||
Or, you can reference an attached property or attached event, independent of the containing object element. (Attached properties are discussed in an upcoming section.)
|
||||
|
||||
You can also name any event from any object that is accessible through the default namespace by using a *typeName*.*event* partially qualified name; this syntax supports attaching handlers for routed events where the handler is intended to handle events routing from child elements, but the parent element does not also have that event in its members table. This syntax resembles an attached event syntax, but the event here is not a true attached event. Instead, you are referencing an event with a qualified name. For more information, see [Routed Events Overview](routed-events-overview.md).
|
||||
|
||||
For some scenarios, property names are sometimes provided as the value of an attribute, rather than the attribute name. That property name can also include qualifiers, such as the property specified in the form *ownerType*.*dependencyPropertyName*. This scenario is common when writing styles or templates in XAML. The processing rules for property names provided as an attribute value are different, and are governed by the type of the property being set or by the behaviors of particular WPF subsystems. For details, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
|
||||
Another usage for property names is when an attribute value describes a property-property relationship. This feature is used for data binding and for storyboard targets, and is enabled by the <xref:System.Windows.PropertyPath> class and its type converter. For a more complete description of the lookup semantics, see [PropertyPath XAML Syntax](propertypath-xaml-syntax.md).
|
||||
|
||||
## Property Element Syntax
|
||||
|
||||
*Property element syntax* is a syntax that diverges somewhat from the basic XML syntax rules for elements. In XML, the value of an attribute is a de facto string, with the only possible variation being which string encoding format is being used. In XAML, you can assign other object elements to be the value of a property. This capability is enabled by the property element syntax. Instead of the property being specified as an attribute within the element tag, the property is specified using an opening element tag in *elementTypeName*.*propertyName* form, the value of the property is specified within, and then the property element is closed.
|
||||
|
||||
Specifically, the syntax begins with a left angle bracket (\<), followed immediately by the type name of the class or structure that the property element syntax is contained within. This is followed immediately by a single dot (.), then by the name of a property, then by a right angle bracket (>). As with attribute syntax, that property must exist within the declared public members of the specified type. The value to be assigned to the property is contained within the property element. Typically, the value is given as one or more object elements, because specifying objects as values is the scenario that property element syntax is intended to address. Finally, an equivalent closing tag specifying the same *elementTypeName*.*propertyName* combination must be provided, in proper nesting and balance with other element tags.
|
||||
|
||||
For example, the following is property element syntax for the <xref:System.Windows.FrameworkElement.ContextMenu%2A> property of a <xref:System.Windows.Controls.Button>.
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#ContextMenu](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/Page1.xaml#contextmenu)]
|
||||
|
||||
The value within a property element can also be given as inner text, in cases where the property type being specified is a primitive value type, such as <xref:System.String>, or an enumeration where a name is specified. These two usages are somewhat uncommon, because each of these cases could also use a simpler attribute syntax. One scenario for filling a property element with a string is for properties that are not the XAML content property but still are used for representation of UI text, and particular white-space elements such as linefeeds are required to appear in that UI text. Attribute syntax cannot preserve linefeeds, but property element syntax can, so long as significant white-space preservation is active (for details, see [White space processing in XAML](/dotnet/desktop-wpf/xaml-services/white-space-processing)). Another scenario is so that [x:Uid Directive](/dotnet/desktop-wpf/xaml-services/xuid-directive) can be applied to the property element and thus mark the value within as a value that should be localized in the WPF output BAML or by other techniques.
|
||||
|
||||
A property element is not represented in the WPF logical tree. A property element is just a particular syntax for setting a property, and is not an element that has an instance or object backing it. (For details on the logical tree concept, see [Trees in WPF](trees-in-wpf.md).)
|
||||
|
||||
For properties where both attribute and property element syntax are supported, the two syntaxes generally have the same result, although subtleties such as white-space handling can vary slightly between syntaxes.
|
||||
|
||||
## Collection Syntax
|
||||
|
||||
The XAML specification requires XAML processor implementations to identify properties where the value type is a collection. The general XAML processor implementation in .NET is based on managed code and the CLR, and it identifies collection types through one of the following:
|
||||
|
||||
- Type implements <xref:System.Collections.IList>.
|
||||
|
||||
- Type implements <xref:System.Collections.IDictionary>.
|
||||
|
||||
- Type derives from <xref:System.Array> (for more information about arrays in XAML, see [x:Array Markup Extension](/dotnet/desktop-wpf/xaml-services/xarray-markup-extension).)
|
||||
|
||||
If the type of a property is a collection, then the inferred collection type does not need to be specified in the markup as an object element. Instead, the elements that are intended to become the items in the collection are specified as one or more child elements of the property element. Each such item is evaluated to an object during loading and added to the collection by calling the `Add` method of the implied collection. For example, the <xref:System.Windows.Style.Triggers%2A> property of <xref:System.Windows.Style> takes the specialized collection type <xref:System.Windows.TriggerCollection>, which implements <xref:System.Collections.IList>. It is not necessary to instantiate a <xref:System.Windows.TriggerCollection> object element in the markup. Instead, you specify one or more <xref:System.Windows.Trigger> items as elements within the `Style.Triggers` property element, where <xref:System.Windows.Trigger> (or a derived class) is the type expected as the item type for the strongly typed and implicit <xref:System.Windows.TriggerCollection>.
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#SyntaxPECollection](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/Page1.xaml#syntaxpecollection)]
|
||||
|
||||
A property may be both a collection type and the XAML content property for that type and derived types, which is discussed in the next section of this topic.
|
||||
|
||||
An implicit collection element creates a member in the logical tree representation, even though it does not appear in the markup as an element. Usually the constructor of the parent type performs the instantiation for the collection that is one of its properties, and the initially empty collection becomes part of the object tree.
|
||||
|
||||
> You can use alternating quotes to place a literal quotation mark within an attribute. For instance you can use single quotes as a means to declare a string that contains a double quote character within it. Whether you use single or double quotes, you should use a matching pair for opening and closing the attribute value string. There are also escape sequences or other techniques available for working around character restrictions imposed by any particular XAML syntax. See [XML Character Entities and XAML](/dotnet/desktop/xaml-services/xml-character-entities).
|
||||
|
||||
In order to be set through attribute syntax, a property must be public and must be writeable. The value of the property in the backing type system must be a value type, or must be a reference type that can be instantiated or referenced by a XAML processor when accessing the relevant backing type.
|
||||
|
||||
For WPF XAML events, the event that is referenced as the attribute name must be public and have a public delegate.
|
||||
|
||||
The property or event must be a member of the class or structure that is instantiated by the containing object element.
|
||||
|
||||
### Processing of Attribute Values
|
||||
The string value contained within the opening and closing quotation marks is processed by a XAML processor. For properties, the default processing behavior is determined by the type of the underlying CLR property.
|
||||
|
||||
The attribute value is filled by one of the following, using this processing order:
|
||||
|
||||
1. If the XAML processor encounters a curly brace, or an object element that derives from <xref:System.Windows.Markup.MarkupExtension>, then the referenced markup extension is evaluated first rather than processing the value as a string, and the object returned by the markup extension is used as the value. In many cases the object returned by a markup extension will be a reference to an existing object, or an expression that defers evaluation until run time, and is not a newly instantiated object.
|
||||
|
||||
2. If the property is declared with an attributed <xref:System.ComponentModel.TypeConverter>, or the value type of that property is declared with an attributed <xref:System.ComponentModel.TypeConverter>, the string value of the attribute is submitted to the type converter as a conversion input, and the converter will return a new object instance.
|
||||
|
||||
3. If there is no <xref:System.ComponentModel.TypeConverter>, a direct conversion to the property type is attempted. This final level is a direct conversion at the parser-native value between XAML language primitive types, or a check for the names of named constants in an enumeration (the parser then accesses the matching values).
|
||||
|
||||
#### Enumeration Attribute Values
|
||||
Enumerations in XAML are processed intrinsically by XAML parsers, and the members of an enumeration should be specified by specifying the string name of one of the enumeration's named constants.
|
||||
|
||||
For nonflag enumeration values, the native behavior is to process the string of an attribute value and resolve it to one of the enumeration values. You do not specify the enumeration in the format *Enumeration*.*Value*, as you do in code. Instead, you specify only *Value*, and *Enumeration* is inferred by the type of the property you are setting. If you specify an attribute in the *Enumeration*.*Value* form, it will not resolve correctly.
|
||||
|
||||
For flagwise enumerations, the behavior is based on the <xref:System.Enum.Parse%2A?displayProperty=nameWithType> method. You can specify multiple values for a flagwise enumeration by separating each value with a comma. However, you cannot combine enumeration values that are not flagwise. For instance, you cannot use the comma syntax to attempt to create a <xref:System.Windows.Trigger> that acts on multiple conditions of a nonflag enumeration:
|
||||
|
||||
```xaml
|
||||
<!--This will not compile, because Visibility is not a flagwise enumeration.-->
|
||||
...
|
||||
<Trigger Property="Visibility" Value="Collapsed,Hidden">
|
||||
<Setter ... />
|
||||
</Trigger>
|
||||
...
|
||||
```
|
||||
|
||||
Flagwise enumerations that support attributes that are settable in XAML are rare in WPF. However, one such enumeration is <xref:System.Windows.Media.StyleSimulations>. You could, for instance, use the comma-delimited flagwise attribute syntax to modify the example provided in the Remarks for the <xref:System.Windows.Documents.Glyphs> class; `StyleSimulations = "BoldSimulation"` could become `StyleSimulations = "BoldSimulation,ItalicSimulation"`. <xref:System.Windows.Input.KeyBinding.Modifiers%2A?displayProperty=nameWithType> is another property where more than one enumeration value can be specified. However, this property happens to be a special case, because the <xref:System.Windows.Input.ModifierKeys> enumeration supports its own type converter. The type converter for modifiers uses a plus sign (+) as a delimiter rather than a comma (,). This conversion supports the more traditional syntax to represent key combinations in Microsoft Windows programming, such as "Ctrl+Alt".
|
||||
|
||||
### Properties and Event Member Name References
|
||||
When specifying an attribute, you can reference any property or event that exists as a member of the CLR type you instantiated for the containing object element.
|
||||
|
||||
Or, you can reference an attached property or attached event, independent of the containing object element. (Attached properties are discussed in an upcoming section.)
|
||||
|
||||
You can also name any event from any object that is accessible through the default namespace by using a *typeName*.*event* partially qualified name; this syntax supports attaching handlers for routed events where the handler is intended to handle events routing from child elements, but the parent element does not also have that event in its members table. This syntax resembles an attached event syntax, but the event here is not a true attached event. Instead, you are referencing an event with a qualified name. For more information, see [Routed Events Overview](routed-events-overview.md).
|
||||
|
||||
For some scenarios, property names are sometimes provided as the value of an attribute, rather than the attribute name. That property name can also include qualifiers, such as the property specified in the form *ownerType*.*dependencyPropertyName*. This scenario is common when writing styles or templates in XAML. The processing rules for property names provided as an attribute value are different, and are governed by the type of the property being set or by the behaviors of particular WPF subsystems. For details, see [Styling and Templating](../controls/styles-templates-overview.md).
|
||||
|
||||
Another usage for property names is when an attribute value describes a property-property relationship. This feature is used for data binding and for storyboard targets, and is enabled by the <xref:System.Windows.PropertyPath> class and its type converter. For a more complete description of the lookup semantics, see [PropertyPath XAML Syntax](propertypath-xaml-syntax.md).
|
||||
|
||||
<a name="property_element_syntax"></a>
|
||||
## Property Element Syntax
|
||||
*Property element syntax* is a syntax that diverges somewhat from the basic XML syntax rules for elements. In XML, the value of an attribute is a de facto string, with the only possible variation being which string encoding format is being used. In XAML, you can assign other object elements to be the value of a property. This capability is enabled by the property element syntax. Instead of the property being specified as an attribute within the element tag, the property is specified using an opening element tag in *elementTypeName*.*propertyName* form, the value of the property is specified within, and then the property element is closed.
|
||||
|
||||
Specifically, the syntax begins with a left angle bracket (\<), followed immediately by the type name of the class or structure that the property element syntax is contained within. This is followed immediately by a single dot (.), then by the name of a property, then by a right angle bracket (>). As with attribute syntax, that property must exist within the declared public members of the specified type. The value to be assigned to the property is contained within the property element. Typically, the value is given as one or more object elements, because specifying objects as values is the scenario that property element syntax is intended to address. Finally, an equivalent closing tag specifying the same *elementTypeName*.*propertyName* combination must be provided, in proper nesting and balance with other element tags.
|
||||
|
||||
For example, the following is property element syntax for the <xref:System.Windows.FrameworkElement.ContextMenu%2A> property of a <xref:System.Windows.Controls.Button>.
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#ContextMenu](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/Page1.xaml#contextmenu)]
|
||||
|
||||
The value within a property element can also be given as inner text, in cases where the property type being specified is a primitive value type, such as <xref:System.String>, or an enumeration where a name is specified. These two usages are somewhat uncommon, because each of these cases could also use a simpler attribute syntax. One scenario for filling a property element with a string is for properties that are not the XAML content property but still are used for representation of UI text, and particular white-space elements such as linefeeds are required to appear in that UI text. Attribute syntax cannot preserve linefeeds, but property element syntax can, so long as significant white-space preservation is active (for details, see [White space processing in XAML](/dotnet/desktop/xaml-services/white-space-processing)). Another scenario is so that [x:Uid Directive](/dotnet/desktop/xaml-services/xuid-directive) can be applied to the property element and thus mark the value within as a value that should be localized in the WPF output BAML or by other techniques.
|
||||
|
||||
A property element is not represented in the WPF logical tree. A property element is just a particular syntax for setting a property, and is not an element that has an instance or object backing it. (For details on the logical tree concept, see [Trees in WPF](trees-in-wpf.md).)
|
||||
|
||||
For properties where both attribute and property element syntax are supported, the two syntaxes generally have the same result, although subtleties such as white-space handling can vary slightly between syntaxes.
|
||||
|
||||
<a name="collection_syntax"></a>
|
||||
## Collection Syntax
|
||||
The XAML specification requires XAML processor implementations to identify properties where the value type is a collection. The general XAML processor implementation in .NET is based on managed code and the CLR, and it identifies collection types through one of the following:
|
||||
|
||||
- Type implements <xref:System.Collections.IList>.
|
||||
|
||||
- Type implements <xref:System.Collections.IDictionary>.
|
||||
|
||||
- Type derives from <xref:System.Array> (for more information about arrays in XAML, see [x:Array Markup Extension](/dotnet/desktop/xaml-services/xarray-markup-extension).)
|
||||
|
||||
If the type of a property is a collection, then the inferred collection type does not need to be specified in the markup as an object element. Instead, the elements that are intended to become the items in the collection are specified as one or more child elements of the property element. Each such item is evaluated to an object during loading and added to the collection by calling the `Add` method of the implied collection. For example, the <xref:System.Windows.Style.Triggers%2A> property of <xref:System.Windows.Style> takes the specialized collection type <xref:System.Windows.TriggerCollection>, which implements <xref:System.Collections.IList>. It is not necessary to instantiate a <xref:System.Windows.TriggerCollection> object element in the markup. Instead, you specify one or more <xref:System.Windows.Trigger> items as elements within the `Style.Triggers` property element, where <xref:System.Windows.Trigger> (or a derived class) is the type expected as the item type for the strongly typed and implicit <xref:System.Windows.TriggerCollection>.
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#SyntaxPECollection](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/Page1.xaml#syntaxpecollection)]
|
||||
|
||||
A property may be both a collection type and the XAML content property for that type and derived types, which is discussed in the next section of this topic.
|
||||
|
||||
An implicit collection element creates a member in the logical tree representation, even though it does not appear in the markup as an element. Usually the constructor of the parent type performs the instantiation for the collection that is one of its properties, and the initially empty collection becomes part of the object tree.
|
||||
|
||||
> [!NOTE]
|
||||
> The generic list and dictionary interfaces (<xref:System.Collections.Generic.IList%601> and <xref:System.Collections.Generic.IDictionary%602>) are not supported for collection detection. However, you can use the <xref:System.Collections.Generic.List%601> class as a base class, because it implements <xref:System.Collections.IList> directly, or <xref:System.Collections.Generic.Dictionary%602> as a base class, because it implements <xref:System.Collections.IDictionary> directly.
|
||||
|
||||
@@ -202,130 +200,124 @@ The value of a XAML content property must be given either entirely before or ent
|
||||
|
||||
```xaml
|
||||
<Button>I am a
|
||||
<Button.Background>Blue</Button.Background>
|
||||
blue button</Button>
|
||||
```
|
||||
|
||||
This is illegal essentially because if this syntax were made explicit by using property element syntax for the content property, then the content property would be set twice:
|
||||
|
||||
```xaml
|
||||
<Button>
|
||||
<Button.Content>I am a </Button.Content>
|
||||
<Button.Background>Blue</Button.Background>
|
||||
<Button.Content> blue button</Button.Content>
|
||||
</Button>
|
||||
```
|
||||
|
||||
A similarly illegal example is if the content property is a collection, and child elements are interspersed with property elements:
|
||||
|
||||
```xaml
|
||||
<StackPanel>
|
||||
<Button>This example</Button>
|
||||
<StackPanel.Resources>
|
||||
<SolidColorBrush x:Key="BlueBrush" Color="Blue"/>
|
||||
</StackPanel.Resources>
|
||||
<Button>... is illegal XAML</Button>
|
||||
</StackPanel>
|
||||
```
|
||||
|
||||
## Content Properties and Collection Syntax Combined
|
||||
|
||||
In order to accept more than a single object element as content, the type of the content property must specifically be a collection type. Similar to property element syntax for collection types, a XAML processor must identify types that are collection types. If an element has a XAML content property and the type of the XAML content property is a collection, then the implied collection type does not need to be specified in the markup as an object element and the XAML content property does not need to be specified as a property element. Therefore the apparent content model in the markup can now have more than one child element assigned as the content. The following is content syntax for a <xref:System.Windows.Controls.Panel> derived class. All <xref:System.Windows.Controls.Panel> derived classes establish the XAML content property to be <xref:System.Windows.Controls.Panel.Children%2A>, which requires a value of type <xref:System.Windows.Controls.UIElementCollection>.
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#SyntaxContent](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/page5.xaml#syntaxcontent)]
|
||||
|
||||
Note that neither the property element for <xref:System.Windows.Controls.Panel.Children%2A> nor the element for the <xref:System.Windows.Controls.UIElementCollection> is required in the markup. This is a design feature of XAML so that recursively contained elements that define a [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] are more intuitively represented as a tree of nested elements with immediate parent-child element relationships, without intervening property element tags or collection objects. In fact, <xref:System.Windows.Controls.UIElementCollection> cannot be specified explicitly in markup as an object element, by design. Because its only intended use is as an implicit collection, <xref:System.Windows.Controls.UIElementCollection> does not expose a public parameterless constructor and thus cannot be instantiated as an object element.
|
||||
|
||||
### Mixing Property Elements and Object Elements in an Object with a Content Property
|
||||
|
||||
The XAML specification declares that a XAML processor can enforce that object elements that are used to fill the XAML content property within an object element must be contiguous, and must not be mixed. This restriction against mixing property elements and content is enforced by the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] XAML processors.
|
||||
|
||||
You can have a child object element as the first immediate markup within an object element. Then you can introduce property elements. Or, you can specify one or more property elements, then content, then more property elements. But once a property element follows content, you cannot introduce any further content, you can only add property elements.
|
||||
|
||||
This content / property element order requirement does not apply to inner text used as content. However, it is still a good markup style to keep inner text contiguous, because significant white space will be difficult to detect visually in the markup if property elements are interspersed with inner text.
|
||||
|
||||
## XAML Namespaces
|
||||
|
||||
None of the preceding syntax examples specified a XAML namespace other than the default XAML namespace. In typical [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications, the default XAML namespace is specified to be the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] namespace. You can specify XAML namespaces other than the default XAML namespace and still use similar syntax. But then, anywhere where a class is named that is not accessible within the default XAML namespace, that class name must be preceded with the prefix of the XAML namespace as mapped to the corresponding CLR namespace. For example, `<custom:Example/>` is object element syntax to instantiate an instance of the `Example` class, where the CLR namespace containing that class (and possibly the external assembly information that contains backing types) was previously mapped to the `custom` prefix.
|
||||
|
||||
For more information about XAML namespaces, see [XAML Namespaces and Namespace Mapping for WPF XAML](xaml-namespaces-and-namespace-mapping-for-wpf-xaml.md).
|
||||
|
||||
## Markup Extensions
|
||||
|
||||
XAML defines a markup extension programming entity that enables an escape from the normal XAML processor handling of string attribute values or object elements, and defers the processing to a backing class. The character that identifies a markup extension to a XAML processor when using attribute syntax is the opening curly brace ({), followed by any character other than a closing curly brace (}). The first string following the opening curly brace must reference the class that provides the particular extension behavior, where the reference may omit the substring "Extension" if that substring is part of the true class name. Thereafter, a single space may appear, and then each succeeding character is used as input by the extension implementation, up until the closing curly brace is encountered.
|
||||
|
||||
The .NET XAML implementation uses the <xref:System.Windows.Markup.MarkupExtension> abstract class as the basis for all of the markup extensions supported by [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] as well as other frameworks or technologies. The markup extensions that [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] specifically implements are often intended to provide a means to reference other existing objects, or to make deferred references to objects that will be evaluated at run time. For example, a simple WPF data binding is accomplished by specifying the `{Binding}` markup extension in place of the value that a particular property would ordinarily take. Many of the WPF markup extensions enable an attribute syntax for properties where an attribute syntax would not otherwise be possible. For example, a <xref:System.Windows.Style> object is a relatively complex type that contains a nested series of objects and properties. Styles in WPF are typically defined as a resource in a <xref:System.Windows.ResourceDictionary>, and then referenced through one of the two WPF markup extensions that request a resource. The markup extension defers the evaluation of the property value to a resource lookup and enables providing the value of the <xref:System.Windows.FrameworkElement.Style%2A> property, taking type <xref:System.Windows.Style>, in attribute syntax as in the following example:
|
||||
|
||||
```xaml
|
||||
<Button Style="{StaticResource MyStyle}">My button</Button>
|
||||
```
|
||||
|
||||
Here, `StaticResource` identifies the <xref:System.Windows.StaticResourceExtension> class providing the markup extension implementation. The next string `MyStyle` is used as the input for the non-default <xref:System.Windows.StaticResourceExtension> constructor, where the parameter as taken from the extension string declares the requested <xref:System.Windows.ResourceKey>. `MyStyle` is expected to be the [x:Key](/dotnet/desktop-wpf/xaml-services/xkey-directive) value of a <xref:System.Windows.Style> defined as a resource. The [StaticResource Markup Extension](staticresource-markup-extension.md) usage requests that the resource be used to provide the <xref:System.Windows.Style> property value through static resource lookup logic at load time.
|
||||
|
||||
For more information about markup extensions, see [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md). For a reference of markup extensions and other XAML programming features enabled in the general .NET XAML implementation, see [XAML Namespace (x:) Language Features](/dotnet/desktop-wpf/xaml-services/namespace-language-features). For WPF-specific markup extensions, see [WPF XAML Extensions](wpf-xaml-extensions.md).
|
||||
|
||||
## Attached Properties
|
||||
|
||||
Attached properties are a programming concept introduced in XAML whereby properties can be owned and defined by a particular type, but set as attributes or property elements on any element. The primary scenario that attached properties are intended for is to enable child elements in a markup structure to report information to a parent element without requiring an extensively shared object model across all elements. Conversely, attached properties can be used by parent elements to report information to child elements. For more information on the purpose of attached properties and how to create your own attached properties, see [Attached Properties Overview](attached-properties-overview.md).
|
||||
|
||||
Attached properties use a syntax that superficially resembles property element syntax, in that you also specify a *typeName*.*propertyName* combination. There are two important differences:
|
||||
|
||||
- You can use the *typeName*.*propertyName* combination even when setting an attached property through attribute syntax. Attached properties are the only case where qualifying the property name is a requirement in an attribute syntax.
|
||||
|
||||
- You can also use property element syntax for attached properties. However, for typical property element syntax, the *typeName* you specify is the object element that contains the property element. If you are referring to an attached property, then the *typeName* is the class that defines the attached property, not the containing object element.
|
||||
|
||||
## Attached Events
|
||||
|
||||
Attached events are another programming concept introduced in XAML where events can be defined by a specific type, but handlers may be attached on any object element. In the WPF implementation, often the type that defines an attached event is a static type that defines a service, and sometimes those attached events are exposed by a routed event alias in types that expose the service. Handlers for attached events are specified through attribute syntax. As with attached events, the attribute syntax is expanded for attached events to allow a *typeName*.*eventName* usage, where *typeName* is the class that provides `Add` and `Remove` event handler accessors for the attached event infrastructure, and *eventName* is the event name.
|
||||
|
||||
## 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:
|
||||
|
||||
|||
|
||||
|-|-|
|
||||
|`<Page`|Opening object element of the root element|
|
||||
|`xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"`|The default ([!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]) XAML namespace|
|
||||
|`xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"`|The XAML language XAML namespace|
|
||||
|`x:Class="ExampleNamespace.ExampleCode"`|The partial class declaration that connects markup to any code-behind defined for the partial class|
|
||||
|`>`|End of object element for the root. Object is not closed yet because the element contains child elements|
|
||||
|
||||
## Optional and Nonrecommended XAML Usages
|
||||
|
||||
The following sections describe XAML usages that are technically supported by XAML processors, but that produce verbosity or other aesthetic issues that interfere with XAML files remaining human-readable when you develop applications that contain XAML sources.
|
||||
|
||||
### Optional Property Element Usages
|
||||
|
||||
Optional property element usages include explicitly writing out element content properties that the XAML processor considers implicit. For example, when you declare the contents of a <xref:System.Windows.Controls.Menu>, you could choose to explicitly declare the <xref:System.Windows.Controls.ItemsControl.Items%2A> collection of the <xref:System.Windows.Controls.Menu> as a `<Menu.Items>` property element tag, and place each <xref:System.Windows.Controls.MenuItem> within `<Menu.Items>`, rather than using the implicit XAML processor behavior that all child elements of a <xref:System.Windows.Controls.Menu> must be a <xref:System.Windows.Controls.MenuItem> and are placed in the <xref:System.Windows.Controls.ItemsControl.Items%2A> collection. Sometimes the optional usages can help to visually clarify the object structure as represented in the markup. Or sometimes an explicit property element usage can avoid markup that is technically functional but visually confusing, such as nested markup extensions within an attribute value.
|
||||
|
||||
### Full typeName.memberName Qualified Attributes
|
||||
|
||||
The *typeName*.*memberName* form for an attribute actually works more universally than just the routed event case. But in other situations that form is superfluous and you should avoid it, if only for reasons of markup style and readability. In the following example, each of the three references to the <xref:System.Windows.Controls.Control.Background%2A> attribute are completely equivalent:
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#TypeNameProp](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/page8.xaml#typenameprop)]
|
||||
|
||||
`Button.Background` works because the qualified lookup for that property on <xref:System.Windows.Controls.Button> is successful (<xref:System.Windows.Controls.Control.Background%2A> was inherited from Control) and <xref:System.Windows.Controls.Button> is the class of the object element or a base class. `Control.Background` works because the <xref:System.Windows.Controls.Control> class actually defines <xref:System.Windows.Controls.Control.Background%2A> and <xref:System.Windows.Controls.Control> is a <xref:System.Windows.Controls.Button> base class.
|
||||
|
||||
However, the following *typeName*.*memberName* form example does not work and is thus shown commented:
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#TypeNameBadProp](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/page8.xaml#typenamebadprop)]
|
||||
|
||||
<xref:System.Windows.Controls.Label> is another derived class of <xref:System.Windows.Controls.Control>, and if you had specified `Label.Background` within a <xref:System.Windows.Controls.Label> object element, this usage would have worked. However, because <xref:System.Windows.Controls.Label> is not the class or base class of <xref:System.Windows.Controls.Button>, the specified XAML processor behavior is to then process `Label.Background` as an attached property. `Label.Background` is not an available attached property, and this usage fails.
|
||||
|
||||
### baseTypeName.memberName Property Elements
|
||||
|
||||
In an analogous way to how the *typeName*.*memberName* form works for attribute syntax, a *baseTypeName*.*memberName* syntax works for property element syntax. For instance, the following syntax works:
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#GoofyPE](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/page8.xaml#goofype)]
|
||||
|
||||
Here, the property element was given as `Control.Background` even though the property element was contained in `Button`.
|
||||
|
||||
But just like *typeName*.*memberName* form for attributes, *baseTypeName*.*memberName* is poor style in markup, and you should avoid it.
|
||||
|
||||
<Button.Background>Blue</Button.Background>
|
||||
blue button</Button>
|
||||
```
|
||||
|
||||
This is illegal essentially because if this syntax were made explicit by using property element syntax for the content property, then the content property would be set twice:
|
||||
|
||||
```xaml
|
||||
<Button>
|
||||
<Button.Content>I am a </Button.Content>
|
||||
<Button.Background>Blue</Button.Background>
|
||||
<Button.Content> blue button</Button.Content>
|
||||
</Button>
|
||||
```
|
||||
|
||||
A similarly illegal example is if the content property is a collection, and child elements are interspersed with property elements:
|
||||
|
||||
```xaml
|
||||
<StackPanel>
|
||||
<Button>This example</Button>
|
||||
<StackPanel.Resources>
|
||||
<SolidColorBrush x:Key="BlueBrush" Color="Blue"/>
|
||||
</StackPanel.Resources>
|
||||
<Button>... is illegal XAML</Button>
|
||||
</StackPanel>
|
||||
```
|
||||
|
||||
<a name="content_properties_and_collection_syntax_combined"></a>
|
||||
## Content Properties and Collection Syntax Combined
|
||||
In order to accept more than a single object element as content, the type of the content property must specifically be a collection type. Similar to property element syntax for collection types, a XAML processor must identify types that are collection types. If an element has a XAML content property and the type of the XAML content property is a collection, then the implied collection type does not need to be specified in the markup as an object element and the XAML content property does not need to be specified as a property element. Therefore the apparent content model in the markup can now have more than one child element assigned as the content. The following is content syntax for a <xref:System.Windows.Controls.Panel> derived class. All <xref:System.Windows.Controls.Panel> derived classes establish the XAML content property to be <xref:System.Windows.Controls.Panel.Children%2A>, which requires a value of type <xref:System.Windows.Controls.UIElementCollection>.
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#SyntaxContent](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/page5.xaml#syntaxcontent)]
|
||||
|
||||
Note that neither the property element for <xref:System.Windows.Controls.Panel.Children%2A> nor the element for the <xref:System.Windows.Controls.UIElementCollection> is required in the markup. This is a design feature of XAML so that recursively contained elements that define a [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] are more intuitively represented as a tree of nested elements with immediate parent-child element relationships, without intervening property element tags or collection objects. In fact, <xref:System.Windows.Controls.UIElementCollection> cannot be specified explicitly in markup as an object element, by design. Because its only intended use is as an implicit collection, <xref:System.Windows.Controls.UIElementCollection> does not expose a public parameterless constructor and thus cannot be instantiated as an object element.
|
||||
|
||||
### Mixing Property Elements and Object Elements in an Object with a Content Property
|
||||
The XAML specification declares that a XAML processor can enforce that object elements that are used to fill the XAML content property within an object element must be contiguous, and must not be mixed. This restriction against mixing property elements and content is enforced by the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] XAML processors.
|
||||
|
||||
You can have a child object element as the first immediate markup within an object element. Then you can introduce property elements. Or, you can specify one or more property elements, then content, then more property elements. But once a property element follows content, you cannot introduce any further content, you can only add property elements.
|
||||
|
||||
This content / property element order requirement does not apply to inner text used as content. However, it is still a good markup style to keep inner text contiguous, because significant white space will be difficult to detect visually in the markup if property elements are interspersed with inner text.
|
||||
|
||||
<a name="xaml_namespaces"></a>
|
||||
## XAML Namespaces
|
||||
None of the preceding syntax examples specified a XAML namespace other than the default XAML namespace. In typical [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] applications, the default XAML namespace is specified to be the [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] namespace. You can specify XAML namespaces other than the default XAML namespace and still use similar syntax. But then, anywhere where a class is named that is not accessible within the default XAML namespace, that class name must be preceded with the prefix of the XAML namespace as mapped to the corresponding CLR namespace. For example, `<custom:Example/>` is object element syntax to instantiate an instance of the `Example` class, where the CLR namespace containing that class (and possibly the external assembly information that contains backing types) was previously mapped to the `custom` prefix.
|
||||
|
||||
For more information about XAML namespaces, see [XAML Namespaces and Namespace Mapping for WPF XAML](xaml-namespaces-and-namespace-mapping-for-wpf-xaml.md).
|
||||
|
||||
<a name="markup_extensions"></a>
|
||||
## Markup Extensions
|
||||
XAML defines a markup extension programming entity that enables an escape from the normal XAML processor handling of string attribute values or object elements, and defers the processing to a backing class. The character that identifies a markup extension to a XAML processor when using attribute syntax is the opening curly brace ({), followed by any character other than a closing curly brace (}). The first string following the opening curly brace must reference the class that provides the particular extension behavior, where the reference may omit the substring "Extension" if that substring is part of the true class name. Thereafter, a single space may appear, and then each succeeding character is used as input by the extension implementation, up until the closing curly brace is encountered.
|
||||
|
||||
The .NET XAML implementation uses the <xref:System.Windows.Markup.MarkupExtension> abstract class as the basis for all of the markup extensions supported by [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] as well as other frameworks or technologies. The markup extensions that [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] specifically implements are often intended to provide a means to reference other existing objects, or to make deferred references to objects that will be evaluated at run time. For example, a simple WPF data binding is accomplished by specifying the `{Binding}` markup extension in place of the value that a particular property would ordinarily take. Many of the WPF markup extensions enable an attribute syntax for properties where an attribute syntax would not otherwise be possible. For example, a <xref:System.Windows.Style> object is a relatively complex type that contains a nested series of objects and properties. Styles in WPF are typically defined as a resource in a <xref:System.Windows.ResourceDictionary>, and then referenced through one of the two WPF markup extensions that request a resource. The markup extension defers the evaluation of the property value to a resource lookup and enables providing the value of the <xref:System.Windows.FrameworkElement.Style%2A> property, taking type <xref:System.Windows.Style>, in attribute syntax as in the following example:
|
||||
|
||||
`<Button Style="{StaticResource MyStyle}">My button</Button>`
|
||||
|
||||
Here, `StaticResource` identifies the <xref:System.Windows.StaticResourceExtension> class providing the markup extension implementation. The next string `MyStyle` is used as the input for the non-default <xref:System.Windows.StaticResourceExtension> constructor, where the parameter as taken from the extension string declares the requested <xref:System.Windows.ResourceKey>. `MyStyle` is expected to be the [x:Key](/dotnet/desktop/xaml-services/xkey-directive) value of a <xref:System.Windows.Style> defined as a resource. The [StaticResource Markup Extension](staticresource-markup-extension.md) usage requests that the resource be used to provide the <xref:System.Windows.Style> property value through static resource lookup logic at load time.
|
||||
|
||||
For more information about markup extensions, see [Markup Extensions and WPF XAML](markup-extensions-and-wpf-xaml.md). For a reference of markup extensions and other XAML programming features enabled in the general .NET XAML implementation, see [XAML Namespace (x:) Language Features](/dotnet/desktop/xaml-services/namespace-language-features). For WPF-specific markup extensions, see [WPF XAML Extensions](wpf-xaml-extensions.md).
|
||||
|
||||
<a name="attached_properties"></a>
|
||||
## Attached Properties
|
||||
Attached properties are a programming concept introduced in XAML whereby properties can be owned and defined by a particular type, but set as attributes or property elements on any element. The primary scenario that attached properties are intended for is to enable child elements in a markup structure to report information to a parent element without requiring an extensively shared object model across all elements. Conversely, attached properties can be used by parent elements to report information to child elements. For more information on the purpose of attached properties and how to create your own attached properties, see [Attached Properties Overview](attached-properties-overview.md).
|
||||
|
||||
Attached properties use a syntax that superficially resembles property element syntax, in that you also specify a *typeName*.*propertyName* combination. There are two important differences:
|
||||
|
||||
- You can use the *typeName*.*propertyName* combination even when setting an attached property through attribute syntax. Attached properties are the only case where qualifying the property name is a requirement in an attribute syntax.
|
||||
|
||||
- You can also use property element syntax for attached properties. However, for typical property element syntax, the *typeName* you specify is the object element that contains the property element. If you are referring to an attached property, then the *typeName* is the class that defines the attached property, not the containing object element.
|
||||
|
||||
<a name="attached_events"></a>
|
||||
## Attached Events
|
||||
Attached events are another programming concept introduced in XAML where events can be defined by a specific type, but handlers may be attached on any object element. In the WOF implementation, often the type that defines an attached event is a static type that defines a service, and sometimes those attached events are exposed by a routed event alias in types that expose the service. Handlers for attached events are specified through attribute syntax. As with attached events, the attribute syntax is expanded for attached events to allow a *typeName*.*eventName* usage, where *typeName* is the class that provides `Add` and `Remove` event handler accessors for the attached event infrastructure, and *eventName* is the event name.
|
||||
|
||||
<a name="anatomy_of_a_xaml_page_root_element"></a>
|
||||
## 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:
|
||||
|
||||
|||
|
||||
|-|-|
|
||||
|`<Page`|Opening object element of the root element|
|
||||
|`xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"`|The default ([!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)]) XAML namespace|
|
||||
|`xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"`|The XAML language XAML namespace|
|
||||
|`x:Class="ExampleNamespace.ExampleCode"`|The partial class declaration that connects markup to any code-behind defined for the partial class|
|
||||
|`>`|End of object element for the root. Object is not closed yet because the element contains child elements|
|
||||
|
||||
<a name="optional_and_nonrecommended_xaml_usages"></a>
|
||||
## Optional and Nonrecommended XAML Usages
|
||||
The following sections describe XAML usages that are technically supported by XAML processors, but that produce verbosity or other aesthetic issues that interfere with XAML files remaining human-readable when you develop applications that contain XAML sources.
|
||||
|
||||
### Optional Property Element Usages
|
||||
Optional property element usages include explicitly writing out element content properties that the XAML processor considers implicit. For example, when you declare the contents of a <xref:System.Windows.Controls.Menu>, you could choose to explicitly declare the <xref:System.Windows.Controls.ItemsControl.Items%2A> collection of the <xref:System.Windows.Controls.Menu> as a `<Menu.Items>` property element tag, and place each <xref:System.Windows.Controls.MenuItem> within `<Menu.Items>`, rather than using the implicit XAML processor behavior that all child elements of a <xref:System.Windows.Controls.Menu> must be a <xref:System.Windows.Controls.MenuItem> and are placed in the <xref:System.Windows.Controls.ItemsControl.Items%2A> collection. Sometimes the optional usages can help to visually clarify the object structure as represented in the markup. Or sometimes an explicit property element usage can avoid markup that is technically functional but visually confusing, such as nested markup extensions within an attribute value.
|
||||
|
||||
### Full typeName.memberName Qualified Attributes
|
||||
The *typeName*.*memberName* form for an attribute actually works more universally than just the routed event case. But in other situations that form is superfluous and you should avoid it, if only for reasons of markup style and readability. In the following example, each of the three references to the <xref:System.Windows.Controls.Control.Background%2A> attribute are completely equivalent:
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#TypeNameProp](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/page8.xaml#typenameprop)]
|
||||
|
||||
`Button.Background` works because the qualified lookup for that property on <xref:System.Windows.Controls.Button> is successful (<xref:System.Windows.Controls.Control.Background%2A> was inherited from Control) and <xref:System.Windows.Controls.Button> is the class of the object element or a base class. `Control.Background` works because the <xref:System.Windows.Controls.Control> class actually defines <xref:System.Windows.Controls.Control.Background%2A> and <xref:System.Windows.Controls.Control> is a <xref:System.Windows.Controls.Button> base class.
|
||||
|
||||
However, the following *typeName*.*memberName* form example does not work and is thus shown commented:
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#TypeNameBadProp](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/page8.xaml#typenamebadprop)]
|
||||
|
||||
<xref:System.Windows.Controls.Label> is another derived class of <xref:System.Windows.Controls.Control>, and if you had specified `Label.Background` within a <xref:System.Windows.Controls.Label> object element, this usage would have worked. However, because <xref:System.Windows.Controls.Label> is not the class or base class of <xref:System.Windows.Controls.Button>, the specified XAML processor behavior is to then process `Label.Background` as an attached property. `Label.Background` is not an available attached property, and this usage fails.
|
||||
|
||||
### baseTypeName.memberName Property Elements
|
||||
In an analogous way to how the *typeName*.*memberName* form works for attribute syntax, a *baseTypeName*.*memberName* syntax works for property element syntax. For instance, the following syntax works:
|
||||
|
||||
[!code-xaml[XAMLOvwSupport#GoofyPE](~/samples/snippets/csharp/VS_Snippets_Wpf/XAMLOvwSupport/CSharp/page8.xaml#goofype)]
|
||||
|
||||
Here, the property element was given as `Control.Background` even though the property element was contained in `Button`.
|
||||
|
||||
But just like *typeName*.*memberName* form for attributes, *baseTypeName*.*memberName* is poor style in markup, and you should avoid it.
|
||||
|
||||
## See also
|
||||
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [XAML Namespace (x:) Language Features](/dotnet/desktop-wpf/xaml-services/namespace-language-features)
|
||||
- [XAML in WPF](xaml-in-wpf.md)
|
||||
- [XAML Namespace (x:) Language Features](/dotnet/desktop/xaml-services/namespace-language-features)
|
||||
- [WPF XAML Extensions](wpf-xaml-extensions.md)
|
||||
- [Dependency Properties Overview](dependency-properties-overview.md)
|
||||
- [TypeConverters and XAML](typeconverters-and-xaml.md)
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ After Windows Presentation Foundation (WPF) applications are built, they need to
|
||||
|
||||
Markup-only [!INCLUDE[TLA2#tla_xaml](../../../includes/tla2sharptla-xaml-md.md)] pages can be installed to the local file system by using either XCopy or Windows Installer. These pages can be viewed using Internet Explorer or Windows Explorer.
|
||||
|
||||
For more information about XAML, see [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml).
|
||||
For more information about XAML, see [XAML in WPF](../advanced/xaml-in-wpf.md).
|
||||
|
||||
<a name="Deploying_XAML_Browser_Applications"></a>
|
||||
|
||||
|
||||
@@ -738,7 +738,7 @@ Like <xref:System.Windows.Controls.Frame>, navigating to HTML using <xref:System
|
||||
|
||||
### Navigating to Custom Objects
|
||||
|
||||
If you have data that is stored as custom objects, one way to display that data is to create a <xref:System.Windows.Controls.Page> with content that is bound to those objects (see [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)). If you don't need the overhead of creating an entire page just to display the objects, you can navigate directly to them instead.
|
||||
If you have data that is stored as custom objects, one way to display that data is to create a <xref:System.Windows.Controls.Page> with content that is bound to those objects (see [Data Binding Overview](../data/data-binding-overview.md)). If you don't need the overhead of creating an entire page just to display the objects, you can navigate directly to them instead.
|
||||
|
||||
Consider the `Person` class that is implemented in the following code.
|
||||
|
||||
|
||||
@@ -452,7 +452,7 @@ Resource dictionaries (<xref:System.Windows.ResourceDictionary>) can be used to
|
||||
|
||||
[!code-xaml[ResourceDictionarySnippets#ResourceDictionaryPackURI](~/samples/snippets/csharp/VS_Snippets_Wpf/ResourceDictionarySnippets/CS/App.xaml#resourcedictionarypackuri)]
|
||||
|
||||
For an overview of themes in WPF, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
For an overview of themes in WPF, see [Styling and Templating](../controls/styles-templates-overview.md).
|
||||
|
||||
## See also
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ helpviewer_keywords:
|
||||
ms.assetid: e223c759-f8c4-4717-acfb-b1e40bdf5f3b
|
||||
---
|
||||
# Button Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Button> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Button> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## Button Parts
|
||||
The <xref:System.Windows.Controls.Button> control does not have any named parts.
|
||||
@@ -49,5 +49,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: f4fcf046-7a8f-41b8-b5a8-534b64e0345c
|
||||
---
|
||||
# Calendar Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Calendar> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Calendar> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## Calendar Parts
|
||||
The following table lists the named parts for the <xref:System.Windows.Controls.Calendar> control.
|
||||
@@ -127,5 +127,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -48,4 +48,4 @@ Calendar controls
|
||||
## See also
|
||||
|
||||
- [Controls](index.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: bfdaec96-d101-4d3d-864d-c27e6b621d03
|
||||
---
|
||||
# CheckBox Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.CheckBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.CheckBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## CheckBox Parts
|
||||
The <xref:System.Windows.Controls.CheckBox> control does not have any named parts.
|
||||
@@ -51,5 +51,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -12,7 +12,7 @@ helpviewer_keywords:
|
||||
ms.assetid: b0662fa1-16d7-4320-b26b-c1804e565a44
|
||||
---
|
||||
# ComboBox Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ComboBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ComboBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## ComboBox Parts
|
||||
The following table lists the named parts for the <xref:System.Windows.Controls.ComboBox> control.
|
||||
@@ -78,5 +78,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 342d1f17-c406-4f94-8f55-867c5f3ea511
|
||||
---
|
||||
# ContextMenu Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ContextMenu> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ContextMenu> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## ContextMenu Parts
|
||||
The <xref:System.Windows.Controls.ContextMenu> control does not have any named parts.
|
||||
@@ -44,5 +44,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -34,7 +34,7 @@ Historically, if you wanted to get a customized experience from an existing cont
|
||||
|
||||
- **Triggers.** A <xref:System.Windows.Trigger> allows you to dynamically change the appearance and behavior of a control without creating a new control. For example, suppose you have multiple <xref:System.Windows.Controls.ListBox> controls in your application and want the items in each <xref:System.Windows.Controls.ListBox> to be bold and red when they are selected. Your first instinct might be to create a class that inherits from <xref:System.Windows.Controls.ListBox> and override the <xref:System.Windows.Controls.Primitives.Selector.OnSelectionChanged%2A> method to change the appearance of the selected item, but a better approach is to add a trigger to a style of a <xref:System.Windows.Controls.ListBoxItem> that changes the appearance of the selected item. A trigger enables you to change property values or take actions based on the value of a property. An <xref:System.Windows.EventTrigger> enables you to take actions when an event occurs.
|
||||
|
||||
For more information about styles, templates, and triggers, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
For more information about styles, templates, and triggers, see [Styling and Templating](styles-templates-overview.md).
|
||||
|
||||
In general, if your control mirrors the functionality of an existing control, but you want the control to look different, you should first consider whether you can use any of the methods discussed in this section to change the existing control's appearance.
|
||||
|
||||
@@ -179,7 +179,7 @@ The following example uses binding to accomplish the same thing.
|
||||
|
||||
[!code-xaml[UserControlNumericUpDown#Binding](~/samples/snippets/csharp/VS_Snippets_Wpf/UserControlNumericUpDown/CSharp/NumericUpDown.xaml#binding)]
|
||||
|
||||
For more information about data binding, see [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
For more information about data binding, see [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
### Design for Designers
|
||||
|
||||
|
||||
@@ -20,4 +20,4 @@ This category covers the various base classes, interfaces and other elements and
|
||||
|
||||
## See also
|
||||
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
|
||||
@@ -70,4 +70,4 @@ Controls in Windows Presentation Foundation (WPF) have a <xref:System.Windows.Co
|
||||
## Related Sections
|
||||
[Control Authoring Overview](control-authoring-overview.md)
|
||||
|
||||
[Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
[Styling and Templating](styles-templates-overview.md)
|
||||
|
||||
+4
-4
@@ -48,7 +48,7 @@ This topic contains the following sections:
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This topic assumes that you know how to create a new <xref:System.Windows.Controls.ControlTemplate> for an existing control, are familiar with what the elements on a control contract are, and understand the concepts discussed in [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic assumes that you know how to create a new <xref:System.Windows.Controls.ControlTemplate> for an existing control, are familiar with what the elements on a control contract are, and understand the concepts discussed in [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
> [!NOTE]
|
||||
> To create a control that can have its appearance customized, you must create a control that inherits from the <xref:System.Windows.Controls.Control> class or one of its subclasses other than <xref:System.Windows.Controls.UserControl>. A control that inherits from <xref:System.Windows.Controls.UserControl> is a control that can be quickly created, but it does not use a <xref:System.Windows.Controls.ControlTemplate> and you cannot customize its appearance.
|
||||
@@ -71,7 +71,7 @@ When you define the visual structure and visual behavior in the <xref:System.Win
|
||||
|
||||
## Defining the Visual Structure and Visual Behavior of a Control in a ControlTemplate
|
||||
|
||||
When you create your custom control by using the parts and states model, you define the control's visual structure and visual behavior in its <xref:System.Windows.Controls.ControlTemplate> instead of in its logic. The visual structure of a control is the composite of <xref:System.Windows.FrameworkElement> objects that make up the control. The visual behavior is the way the control appears when it is in a certain state. For more information about creating a <xref:System.Windows.Controls.ControlTemplate> that specifies the visual structure and visual behavior of a control, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
When you create your custom control by using the parts and states model, you define the control's visual structure and visual behavior in its <xref:System.Windows.Controls.ControlTemplate> instead of in its logic. The visual structure of a control is the composite of <xref:System.Windows.FrameworkElement> objects that make up the control. The visual behavior is the way the control appears when it is in a certain state. For more information about creating a <xref:System.Windows.Controls.ControlTemplate> that specifies the visual structure and visual behavior of a control, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
In the example of the `NumericUpDown` control, the visual structure includes two <xref:System.Windows.Controls.Primitives.RepeatButton> controls and a <xref:System.Windows.Controls.TextBlock>. If you add these controls in the code of the `NumericUpDown` control--in its constructor, for example--the positions of those controls would be unalterable. Instead of defining the control's visual structure and visual behavior in its code, you should define it in the <xref:System.Windows.Controls.ControlTemplate>. Then an application developer to customize the position of the buttons and <xref:System.Windows.Controls.TextBlock> and specify what behavior occurs when `Value` is negative because the <xref:System.Windows.Controls.ControlTemplate> can be replaced.
|
||||
|
||||
@@ -79,7 +79,7 @@ The following example shows the visual structure of the `NumericUpDown` control,
|
||||
|
||||
[!code-xaml[VSMCustomControl#VisualStructure](~/samples/snippets/csharp/VS_Snippets_Wpf/vsmcustomcontrol/csharp/window1.xaml#visualstructure)]
|
||||
|
||||
A visual behavior of the `NumericUpDown` control is that the value is in a red font if it is negative. If you change the <xref:System.Windows.Controls.TextBlock.Foreground%2A> of the <xref:System.Windows.Controls.TextBlock> in code when the `Value` is negative, the `NumericUpDown` will always show a red negative value. You specify the visual behavior of the control in the <xref:System.Windows.Controls.ControlTemplate> by adding <xref:System.Windows.VisualState> objects to the <xref:System.Windows.Controls.ControlTemplate>. The following example shows the <xref:System.Windows.VisualState> objects for the `Positive` and `Negative` states. `Positive` and `Negative` are mutually exclusive (the control is always in exactly one of the two), so the example puts the <xref:System.Windows.VisualState> objects into a single <xref:System.Windows.VisualStateGroup>. When the control goes into the `Negative` state, the <xref:System.Windows.Controls.TextBlock.Foreground%2A> of the <xref:System.Windows.Controls.TextBlock> turns red. When the control is in the `Positive` state, the <xref:System.Windows.Controls.TextBlock.Foreground%2A> returns to its original value. Defining <xref:System.Windows.VisualState> objects in a <xref:System.Windows.Controls.ControlTemplate> is further discussed in [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
A visual behavior of the `NumericUpDown` control is that the value is in a red font if it is negative. If you change the <xref:System.Windows.Controls.TextBlock.Foreground%2A> of the <xref:System.Windows.Controls.TextBlock> in code when the `Value` is negative, the `NumericUpDown` will always show a red negative value. You specify the visual behavior of the control in the <xref:System.Windows.Controls.ControlTemplate> by adding <xref:System.Windows.VisualState> objects to the <xref:System.Windows.Controls.ControlTemplate>. The following example shows the <xref:System.Windows.VisualState> objects for the `Positive` and `Negative` states. `Positive` and `Negative` are mutually exclusive (the control is always in exactly one of the two), so the example puts the <xref:System.Windows.VisualState> objects into a single <xref:System.Windows.VisualStateGroup>. When the control goes into the `Negative` state, the <xref:System.Windows.Controls.TextBlock.Foreground%2A> of the <xref:System.Windows.Controls.TextBlock> turns red. When the control is in the `Positive` state, the <xref:System.Windows.Controls.TextBlock.Foreground%2A> returns to its original value. Defining <xref:System.Windows.VisualState> objects in a <xref:System.Windows.Controls.ControlTemplate> is further discussed in [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
> [!NOTE]
|
||||
> Be sure to set the <xref:System.Windows.VisualStateManager.VisualStateGroups%2A?displayProperty=nameWithType> attached property on the root <xref:System.Windows.FrameworkElement> of the <xref:System.Windows.Controls.ControlTemplate>.
|
||||
@@ -249,5 +249,5 @@ The following example shows the logic for the `NumericUpDown`.
|
||||
|
||||
## See also
|
||||
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
|
||||
@@ -12,7 +12,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 9cb31d63-f148-4d25-b079-816e73f988c7
|
||||
---
|
||||
# DataGrid Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.DataGrid> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.DataGrid> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## DataGrid Parts
|
||||
The following table lists the named parts for the <xref:System.Windows.Controls.DataGrid> control.
|
||||
@@ -170,5 +170,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -54,8 +54,8 @@ The <xref:System.Windows.Controls.DataGrid> control enables you to display and e
|
||||
## See also
|
||||
|
||||
- <xref:System.Windows.Controls.DataGrid>
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Data Templating Overview](../data/data-templating-overview.md)
|
||||
- [Controls](index.md)
|
||||
- [WPF Content Model](wpf-content-model.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: c430a657-692f-44bd-a549-2341f92d6115
|
||||
---
|
||||
# DatePicker Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.DatePicker> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.DatePicker> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## DatePicker Parts
|
||||
The following table lists the named parts for the <xref:System.Windows.Controls.DatePicker> control.
|
||||
@@ -76,5 +76,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -21,4 +21,4 @@ DatePicker Control
|
||||
## See also
|
||||
|
||||
- [Controls](index.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 6bd4ff8f-ea6a-4084-ac58-e7a67446ce1c
|
||||
---
|
||||
# DocumentViewer Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.DocumentViewer> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.DocumentViewer> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## DocumentViewer Parts
|
||||
The following table lists the named parts for the <xref:System.Windows.Controls.DocumentViewer> control.
|
||||
@@ -47,5 +47,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: da2e5a1c-5230-4c21-98a5-59c7895facd7
|
||||
---
|
||||
# Expander Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Expander> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Expander> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## Expander Parts
|
||||
The <xref:System.Windows.Controls.Expander> control does not have any named parts.
|
||||
@@ -53,5 +53,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: a01c32e2-c951-46a0-a82f-2614ca241f0b
|
||||
---
|
||||
# Frame Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Frame> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Frame> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## Frame Parts
|
||||
The following table lists the named parts for the <xref:System.Windows.Controls.Frame> control.
|
||||
@@ -46,5 +46,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 33df7037-0a1b-476f-b9d0-41566a777699
|
||||
---
|
||||
# GroupBox Styles and Templates
|
||||
<a name="introduction"></a> This topic describes the styles and templates for the <xref:System.Windows.Controls.GroupBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
<a name="introduction"></a> This topic describes the styles and templates for the <xref:System.Windows.Controls.GroupBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
<a name="groupbox_parts"></a>
|
||||
## GroupBox Parts
|
||||
@@ -45,5 +45,5 @@ ms.assetid: 33df7037-0a1b-476f-b9d0-41566a777699
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ This document summarizes a set of best practices to consider when designing a co
|
||||
|
||||
- Data templates.
|
||||
|
||||
For an introduction to styling and templating, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
For an introduction to styling and templating, see [Styling and Templating](styles-templates-overview.md).
|
||||
|
||||
<a name="Before_You_Start__Understanding_Your_Control"></a>
|
||||
|
||||
@@ -121,5 +121,5 @@ To understand your control's common usage, it's good to think about the value pr
|
||||
|
||||
## See also
|
||||
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Control Authoring Overview](control-authoring-overview.md)
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ When using the <xref:System.Windows.Controls.DataGrid> control, you can customiz
|
||||
|
||||
[!code-xaml[DataGrid_RowDetails#3](~/samples/snippets/csharp/VS_Snippets_Wpf/datagrid_rowdetails/cs/app.xaml#3)]
|
||||
|
||||
4. On the <xref:System.Windows.DataTemplate>, set the [x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive) to a value that uniquely identifies the data template.
|
||||
4. On the <xref:System.Windows.DataTemplate>, set the [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive) to a value that uniquely identifies the data template.
|
||||
|
||||
5. In the <xref:System.Windows.Controls.DataGrid> element, set the <xref:System.Windows.Controls.DataGrid.RowDetailsTemplate%2A> property to the resource defined in the previous steps. Assign the resource as a static resource.
|
||||
|
||||
|
||||
+1
-1
@@ -21,5 +21,5 @@ There might be times when you want to bind a <xref:System.Windows.Controls.TreeV
|
||||
|
||||
## See also
|
||||
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Data Templating Overview](../data/data-templating-overview.md)
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ By default, the content of each column in a <xref:System.Windows.Controls.ListVi
|
||||
|
||||
## See also
|
||||
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Data Templating Overview](../data/data-templating-overview.md)
|
||||
- [Bind to XML Data Using an XMLDataProvider and XPath Queries](../data/how-to-bind-to-xml-data-using-an-xmldataprovider-and-xpath-queries.md)
|
||||
- [ListView Overview](listview-overview.md)
|
||||
|
||||
+1
-1
@@ -25,6 +25,6 @@ This example shows how to find elements that are generated by a <xref:System.Win
|
||||
## See also
|
||||
|
||||
- [Find DataTemplate-Generated Elements](../data/how-to-find-datatemplate-generated-elements.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [WPF XAML Namescopes](../advanced/wpf-xaml-namescopes.md)
|
||||
- [Trees in WPF](../advanced/trees-in-wpf.md)
|
||||
|
||||
+3
-3
@@ -38,9 +38,9 @@ To group, sort, and filter data in a <xref:System.Windows.Controls.DataGrid> con
|
||||
[!code-csharp[DataGrid_GroupSortFilter#101](~/samples/snippets/csharp/VS_Snippets_Wpf/DataGrid_GroupSortFilter/CS/MainWindow.xaml.cs#101)]
|
||||
[!code-vb[DataGrid_GroupSortFilter#101](~/samples/snippets/visualbasic/VS_Snippets_Wpf/DataGrid_GroupSortFilter/VB/MainWindow.xaml.vb#101)]
|
||||
|
||||
2. In XAML, create an instance of the collection class and set the [x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive).
|
||||
2. In XAML, create an instance of the collection class and set the [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive).
|
||||
|
||||
3. In XAML, create an instance of the <xref:System.Windows.Data.CollectionViewSource> class, set the [x:Key Directive](/dotnet/desktop-wpf/xaml-services/xkey-directive), and set the instance of your collection class as the <xref:System.Windows.Data.CollectionViewSource.Source%2A>.
|
||||
3. In XAML, create an instance of the <xref:System.Windows.Data.CollectionViewSource> class, set the [x:Key Directive](/dotnet/desktop/xaml-services/xkey-directive), and set the instance of your collection class as the <xref:System.Windows.Data.CollectionViewSource.Source%2A>.
|
||||
|
||||
[!code-xaml[DataGrid_GroupSortFilter#201](~/samples/snippets/csharp/VS_Snippets_Wpf/DataGrid_GroupSortFilter/CS/WindowSnips1.xaml#201)]
|
||||
|
||||
@@ -142,7 +142,7 @@ To test this example, you will need to adjust the DGGroupSortFilterExample name
|
||||
|
||||
## See also
|
||||
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Create and Bind to an ObservableCollection](../data/how-to-create-and-bind-to-an-observablecollection.md)
|
||||
- [Filter Data in a View](../data/how-to-filter-data-in-a-view.md)
|
||||
- [Sort Data in a View](../data/how-to-sort-data-in-a-view.md)
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ To handle an event for an item in a <xref:System.Windows.Controls.ListView>, you
|
||||
## See also
|
||||
|
||||
- <xref:System.Xml.XmlElement>
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Bind to XML Data Using an XMLDataProvider and XPath Queries](../data/how-to-bind-to-xml-data-using-an-xmldataprovider-and-xpath-queries.md)
|
||||
- [ListView Overview](listview-overview.md)
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ The <xref:System.Windows.Controls.DataGrid> control enables you to perform valid
|
||||
|
||||
### To validate individual cell values
|
||||
|
||||
- Specify one or more validation rules on the binding used with a column. This is similar to validating data in simple controls, as described in [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview).
|
||||
- Specify one or more validation rules on the binding used with a column. This is similar to validating data in simple controls, as described in [Data Binding Overview](../data/data-binding-overview.md).
|
||||
|
||||
The following example shows a <xref:System.Windows.Controls.DataGrid> control with four columns bound to different properties of a business object. Three of the columns specify the <xref:System.Windows.Controls.ExceptionValidationRule> by setting the <xref:System.Windows.Data.Binding.ValidatesOnExceptions%2A> property to `true`.
|
||||
|
||||
@@ -89,6 +89,6 @@ The <xref:System.Windows.Controls.DataGrid> control enables you to perform valid
|
||||
|
||||
- <xref:System.Windows.Controls.DataGrid>
|
||||
- [DataGrid](datagrid.md)
|
||||
- [Data Binding](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding](../data/data-binding-overview.md)
|
||||
- [Implement Binding Validation](../data/how-to-implement-binding-validation.md)
|
||||
- [Implement Validation Logic on Custom Objects](../data/how-to-implement-validation-logic-on-custom-objects.md)
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ ms.assetid: bcd25fc7-a52f-4453-b802-2c8d2b335ab8
|
||||
This example shows how to use the <xref:System.Windows.Controls.TextBox.Text%2A> property to set the initial text contents of a <xref:System.Windows.Controls.TextBox> control.
|
||||
|
||||
> [!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 Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml).
|
||||
> 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
|
||||
|
||||
|
||||
+1
-1
@@ -33,4 +33,4 @@ This example shows how to style a row in a <xref:System.Windows.Controls.ListVie
|
||||
- <xref:System.Windows.Controls.GridView>
|
||||
- [How-to Topics](listview-how-to-topics.md)
|
||||
- [ListView Overview](listview-overview.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
|
||||
@@ -36,4 +36,4 @@ The <xref:System.Windows.Controls.ToolBar> defines <xref:System.Windows.Resource
|
||||
|
||||
## See also
|
||||
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
|
||||
@@ -49,14 +49,14 @@ ms.assetid: 3f255a8a-35a8-4712-9065-472ff7d75599
|
||||
|
||||
[!code-xaml[ControlsOverview#5](~/samples/snippets/csharp/VS_Snippets_Wpf/ControlsOverview/CSharp/AppInCode.xaml#5)]
|
||||
|
||||
You can also apply a style to only certain controls of a specific type by assigning a key to the style and specifying that key in the `Style` property of your control. For more information about styles, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
You can also apply a style to only certain controls of a specific type by assigning a key to the style and specifying that key in the `Style` property of your control. For more information about styles, see [Styling and Templating](styles-templates-overview.md).
|
||||
|
||||
### Creating a ControlTemplate
|
||||
A <xref:System.Windows.Style> allows you to set properties on multiple controls at a time, but sometimes you might want to customize the appearance of a <xref:System.Windows.Controls.Control> beyond what you can do by creating a <xref:System.Windows.Style>. Classes that inherit from the <xref:System.Windows.Controls.Control> class have a <xref:System.Windows.Controls.ControlTemplate>, which defines the structure and appearance of a <xref:System.Windows.Controls.Control>. The <xref:System.Windows.Controls.Control.Template%2A> property of a <xref:System.Windows.Controls.Control> is public, so you can give a <xref:System.Windows.Controls.Control> a <xref:System.Windows.Controls.ControlTemplate> that is different than its default. You can often specify a new <xref:System.Windows.Controls.ControlTemplate> for a <xref:System.Windows.Controls.Control> instead of inheriting from a control to customize the appearance of a <xref:System.Windows.Controls.Control>.
|
||||
|
||||
Consider the very common control, <xref:System.Windows.Controls.Button>. The primary behavior of a <xref:System.Windows.Controls.Button> is to enable an application to take some action when the user clicks it. By default, the <xref:System.Windows.Controls.Button> in [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] appears as a raised rectangle. While developing an application, you might want to take advantage of the behavior of a <xref:System.Windows.Controls.Button>--that is, by handling the button's click event--but you might change the button's appearance beyond what you can do by changing the button's properties. In this case, you can create a new <xref:System.Windows.Controls.ControlTemplate>.
|
||||
|
||||
The following example creates a <xref:System.Windows.Controls.ControlTemplate> for a <xref:System.Windows.Controls.Button>. The <xref:System.Windows.Controls.ControlTemplate> creates a <xref:System.Windows.Controls.Button> with rounded corners and a gradient background. The <xref:System.Windows.Controls.ControlTemplate> contains a <xref:System.Windows.Controls.Border> whose <xref:System.Windows.Controls.Border.Background%2A> is a <xref:System.Windows.Media.LinearGradientBrush> with two <xref:System.Windows.Media.GradientStop> objects. The first <xref:System.Windows.Media.GradientStop> uses data binding to bind the <xref:System.Windows.Media.GradientStop.Color%2A> property of the <xref:System.Windows.Media.GradientStop> to the color of the button's background. When you set the <xref:System.Windows.Controls.Control.Background%2A> property of the <xref:System.Windows.Controls.Button>, the color of that value will be used as the first <xref:System.Windows.Media.GradientStop>. For more information about data binding, see [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview). The example also creates a <xref:System.Windows.Trigger> that changes the appearance of the <xref:System.Windows.Controls.Button> when <xref:System.Windows.Controls.Primitives.ButtonBase.IsPressed%2A> is `true`.
|
||||
The following example creates a <xref:System.Windows.Controls.ControlTemplate> for a <xref:System.Windows.Controls.Button>. The <xref:System.Windows.Controls.ControlTemplate> creates a <xref:System.Windows.Controls.Button> with rounded corners and a gradient background. The <xref:System.Windows.Controls.ControlTemplate> contains a <xref:System.Windows.Controls.Border> whose <xref:System.Windows.Controls.Border.Background%2A> is a <xref:System.Windows.Media.LinearGradientBrush> with two <xref:System.Windows.Media.GradientStop> objects. The first <xref:System.Windows.Media.GradientStop> uses data binding to bind the <xref:System.Windows.Media.GradientStop.Color%2A> property of the <xref:System.Windows.Media.GradientStop> to the color of the button's background. When you set the <xref:System.Windows.Controls.Control.Background%2A> property of the <xref:System.Windows.Controls.Button>, the color of that value will be used as the first <xref:System.Windows.Media.GradientStop>. For more information about data binding, see [Data Binding Overview](../data/data-binding-overview.md). The example also creates a <xref:System.Windows.Trigger> that changes the appearance of the <xref:System.Windows.Controls.Button> when <xref:System.Windows.Controls.Primitives.ButtonBase.IsPressed%2A> is `true`.
|
||||
|
||||
[!code-xaml[ControlsOverview#6](~/samples/snippets/csharp/VS_Snippets_Wpf/ControlsOverview/CSharp/Window1.xaml#6)]
|
||||
[!code-xaml[ControlsOverview#7](~/samples/snippets/csharp/VS_Snippets_Wpf/ControlsOverview/CSharp/AppInCode.xaml#7)]
|
||||
@@ -94,11 +94,11 @@ ms.assetid: 3f255a8a-35a8-4712-9065-472ff7d75599
|
||||
|
||||
## See also
|
||||
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Controls by Category](controls-by-category.md)
|
||||
- [Control Library](control-library.md)
|
||||
- [Data Templating Overview](../data/data-templating-overview.md)
|
||||
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
- [Data Binding Overview](../data/data-binding-overview.md)
|
||||
- [Input](../advanced/input-wpf.md)
|
||||
- [Enable a Command](../advanced/how-to-enable-a-command.md)
|
||||
- [Walkthroughs: Create a Custom Animated Button](walkthroughs-create-a-custom-animated-button.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: c1d5359a-8e4a-4925-ab3e-e92bf6694859
|
||||
---
|
||||
# Label Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Label> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Label> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## Label Parts
|
||||
The <xref:System.Windows.Controls.Label> control does not have any named parts.
|
||||
@@ -42,5 +42,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: fc5764cb-c27b-495b-88d4-d969a8213ccb
|
||||
---
|
||||
# ListBox Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ListBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ListBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## ListBox Parts
|
||||
The <xref:System.Windows.Controls.ListBox> control does not have any named parts.
|
||||
@@ -64,5 +64,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: d2387356-2171-4785-822a-7247e024b4ee
|
||||
---
|
||||
# ListView Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ListView> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ListView> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## ListView Parts
|
||||
The <xref:System.Windows.Controls.ListView> control does not have any named parts.
|
||||
@@ -64,5 +64,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -25,5 +25,5 @@ The <xref:System.Windows.Controls.ListView> control provides the infrastructure
|
||||
<xref:System.Windows.Controls.GridView>
|
||||
|
||||
## Related Sections
|
||||
[Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
||||
[Data Binding Overview](../data/data-binding-overview.md)
|
||||
[Data Templating Overview](../data/data-templating-overview.md)
|
||||
|
||||
@@ -12,7 +12,7 @@ helpviewer_keywords:
|
||||
ms.assetid: b89da183-9b87-42c6-ac53-731a42c7b09e
|
||||
---
|
||||
# Menu Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Menu> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.Menu> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## Menu Parts
|
||||
The <xref:System.Windows.Controls.Menu> control does not have any named parts.
|
||||
@@ -71,5 +71,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 3656055e-3222-43c8-b868-fd0c90cc31a3
|
||||
---
|
||||
# NavigationWindow Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Navigation.NavigationWindow> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Navigation.NavigationWindow> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## NavigationWindow Parts
|
||||
The following table lists the named parts for the <xref:System.Windows.Navigation.NavigationWindow> control.
|
||||
@@ -47,5 +47,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Navig
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -13,7 +13,7 @@ ms.assetid: deb52107-959f-4a60-b303-d21a0a933060
|
||||
|
||||
# PasswordBox Styles and Templates
|
||||
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.PasswordBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.PasswordBox> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## PasswordBox Parts
|
||||
|
||||
@@ -56,5 +56,5 @@ For the complete sample, see [Styling with ControlTemplates Sample](https://gith
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 935aa600-16e6-4947-a905-37a189a583dd
|
||||
---
|
||||
# ProgressBar Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ProgressBar> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.ProgressBar> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## ProgressBar Parts
|
||||
The following table lists the named parts for the <xref:System.Windows.Controls.ProgressBar> control.
|
||||
@@ -50,5 +50,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 9acf93f7-dd2f-4010-8ce0-1edd81c52ae2
|
||||
---
|
||||
# RadioButton Styles and Templates
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.RadioButton> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template).
|
||||
This topic describes the styles and templates for the <xref:System.Windows.Controls.RadioButton> control. You can modify the default <xref:System.Windows.Controls.ControlTemplate> to give the control a unique appearance. For more information, see [Create a template for a control](how-to-create-apply-template.md).
|
||||
|
||||
## RadioButton Parts
|
||||
The <xref:System.Windows.Controls.RadioButton> control does not have any named parts.
|
||||
@@ -51,5 +51,5 @@ This topic describes the styles and templates for the <xref:System.Windows.Contr
|
||||
- <xref:System.Windows.Controls.ControlTemplate>
|
||||
- [Control Styles and Templates](control-styles-and-templates.md)
|
||||
- [Control Customization](control-customization.md)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)
|
||||
- [Styling and Templating](styles-templates-overview.md)
|
||||
- [Create a template for a control](how-to-create-apply-template.md)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user