From a856d83f289be5511e988ae9792999ec64f9cbb4 Mon Sep 17 00:00:00 2001 From: Andy De George <67293991+adegeo@users.noreply.github.com> Date: Fri, 15 Jan 2021 10:23:49 -0800 Subject: [PATCH] Add note about x:key conflict with explicit keys (#166) * Update how-to-use-an-application-scope-resource-dictionary.md * Update how-to-use-an-application-scope-resource-dictionary.md --- .../how-to-use-an-application-scope-resource-dictionary.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/how-to-use-an-application-scope-resource-dictionary.md b/dotnet-desktop-guide/framework/wpf/app-development/how-to-use-an-application-scope-resource-dictionary.md index 15a7561..4162972 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/how-to-use-an-application-scope-resource-dictionary.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/how-to-use-an-application-scope-resource-dictionary.md @@ -37,7 +37,9 @@ This example shows how to define and use an application-scope custom resource di [!code-vb[HOWTOResourceDictionaries#3](~/samples/snippets/visualbasic/VS_Snippets_Wpf/HowToResourceDictionaries/VB/MainWindow.xaml.vb#3)] There are two considerations to make when using . First, the dictionary *key* is an object, so you must use exactly the same object instance when both setting and getting a property value. (Note that the key is case-sensitive when using a string.) Second, the dictionary *value* is an object, so you will have to convert the value to the desired type when getting a property value. - + +Some resource types may automatically use a property defined by the type as an explicit key, such as the and types. This may override your `x:Key` value. To guarantee that your `x:Key` key is respected, declare it before the explicit key property. For more information, see [Styles, DataTemplates, and implicit keys](../advanced/xaml-resources-define.md#styles-datatemplates-and-implicit-keys). + ## See also -