How to Access a 'Key' of a Resource Dictionary ?
3 posts
• Page 1 of 1
How to Access a 'Key' of a Resource Dictionary ?
If you save the following Xaml into a variable called 'dic':
than you get the corresponding ResourceDictionary object doing:
than if you try to obtain a resource using a key like:
it does not work (NONCE ERROR). My question is: What is the proper way to extract a resource using a key from a resource dictionary object ?
Thanks
- Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="ItemNormalBorderBrush" Color="#8C8E94"/>
<SolidColorBrush x:Key="ItemNormalBackgroundBrush" Color="#FFE6E6E6"/>
<SolidColorBrush x:Key="ItemHotBorderBrush" Color="#FF5CACFF"/>
<SolidColorBrush x:Key="ItemHotBackgroundBrush" Color="#FFC2E0FF"/>
<SolidColorBrush x:Key="ItemSelectedBorderBrush" Color="#FF3399FF"/>
<SolidColorBrush x:Key="ItemSelectedBackgroundBrush" Color="#FF99CCFF"/>
<SolidColorBrush x:Key="ItemDisabledBorderBrush" Color="#FFC9C7BA"/>
<SolidColorBrush x:Key="ItemDisabledBackgroundBrush" Color="#F4F4F4"/>
<SolidColorBrush x:Key="ItemDisabledForegroundBrush" Color="#FF808080"/>
</ResourceDictionary>
than you get the corresponding ResourceDictionary object doing:
⎕USING←('System.Windows.Markup,WPF/PresentationFramework.dll')
rDic←XamlReader.Parse(⊂dic)
than if you try to obtain a resource using a key like:
rDic.Item(⊂'ItemNormalBackgroundBrush')
it does not work (NONCE ERROR). My question is: What is the proper way to extract a resource using a key from a resource dictionary object ?
Thanks
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: How to Access a 'Key' of a Resource Dictionary ?
The issue here is that Item is defined as a property and Dyalog presents that as an indexable array, and allows non-numeric indexers on the property.
So, you should use:
rDic.Item[⊂'ItemNormalBackgroundBrush']
Note that you still need to enclose the character vector.
Best Regards,
John Daintree.
P.S. I've not tested this specific solution.
So, you should use:
rDic.Item[⊂'ItemNormalBackgroundBrush']
Note that you still need to enclose the character vector.
Best Regards,
John Daintree.
P.S. I've not tested this specific solution.
-
JohnD|Dyalog - Posts: 74
- Joined: Wed Oct 01, 2008 9:35 am
Re: How to Access a 'Key' of a Resource Dictionary ?
Many Thanks John, it worked.
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group