mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-05 07:56:11 +02:00
* add toc/bread changes * add xaml-services * add ported wpf content * add xaml-services info to docfx * Fix links 1 * Fix links 2 * Fix links 3 * Fix links 4 * Fix links 5 * Fix links 6 * Fix links 7 * Fix xaml-services link * Fix snippets 1 * Fix snippets 2 * adjust breadcrumb and toc * remove preserve-view from breadcrumbs * add empty view to toc item xaml * update include * remove contextual toc for vs article :(
46 lines
2.9 KiB
Markdown
46 lines
2.9 KiB
Markdown
---
|
|
title: "x:Uid Directive"
|
|
ms.date: "03/30/2017"
|
|
helpviewer_keywords:
|
|
- "XAML [XAML Services], localizable content attribute"
|
|
- "XAML [XAML Services], x:Uid attribute"
|
|
- "x:Uid attribute [XAML Services]"
|
|
- "Uid attribute [XAML Services]"
|
|
ms.assetid: 81defade-483b-4a89-b76d-9b25bba34010
|
|
---
|
|
# x:Uid Directive
|
|
|
|
Provides a unique identifier for markup elements. In many scenarios, this unique identifier is used by XAML localization processes and tools.
|
|
|
|
## XAML Attribute Usage
|
|
|
|
```xaml
|
|
<object x:Uid="identifier"... />
|
|
```
|
|
|
|
## XAML Values
|
|
|
|
|||
|
|
|-|-|
|
|
|`identifier`|A manually created or autogenerated string that should be unique in a file when it is interpreted by an `x:Uid` consumer.|
|
|
|
|
## Remarks
|
|
|
|
In [MS-XAML], `x:Uid` is defined as a directive. For more information, see [\[MS-XAML\] Section 5.3.6](https://docs.microsoft.com/previous-versions/msp-n-p/ff650760(v=pandp.10)).
|
|
|
|
`x:Uid` is discrete from `x:Name` both because of the stated XAML localization scenario and so that identifiers that are used for localization have no dependencies on the programming model implications of `x:Name`. Also, `x:Name` is governed by the XAML namescope; however, `x:Uid` is not governed by any XAML language defined concept of uniqueness enforcement. XAML processors in a broad sense (processors that are not part of the localization process) are not expected to enforce uniqueness of `x:Uid` values. That responsibility is conceptually on the originator of the values. The expectation of uniqueness of `x:Uid` values within a single XAML source is reasonable for consumers of the values, such as dedicated globalization processes or tools. The typical uniqueness model is that `x:Uid` values are unique within an XML-encoded file that represents XAML.
|
|
|
|
Tools that have significant knowledge of a particular XAML schema can choose to apply `x:Uid` only for true localizable strings, instead of for all cases where a text string value is encountered in markup.
|
|
|
|
Frameworks can specify a particular property in their object model to be an alias for `x:Uid` by applying the attribute <xref:System.Windows.Markup.UidPropertyAttribute> to the defining type. If a framework specifies a particular property, it is not valid to specify both `x:Uid` and the aliased member on the same object. If both `x:Uid` and the aliased member are specified, .NET XAML Services API typically throws <xref:System.Xaml.XamlDuplicateMemberException> for this case.
|
|
|
|
## WPF Usage Notes
|
|
|
|
For more information about the role of `x:Uid` in the WPF localization process and in the BAML form of XAML, see [Globalization for WPF](../framework/wpf/advanced/globalization-for-wpf.md) or <xref:System.Windows.Markup.Localizer.BamlLocalizableResourceKey.Uid%2A>
|
|
|
|
## See also
|
|
|
|
- <xref:System.Windows.Markup.Localizer.BamlLocalizableResourceKey.Uid%2A>
|
|
- <xref:Microsoft.Build.Tasks.Windows.UidManager>
|
|
- [Globalization for WPF](../framework/wpf/advanced/globalization-for-wpf.md)
|