|
|
|
How to assign a dynamic resource link programmatically
Normally you assign resources in XAML by using the StaticResource or DynamicResource extension. But how to do it programmatically?
The static behavior is simple. Just find the resource by using the TryFindResource() method and set it to the property of your choice. But if you want to have it dynamically updated, the following code snipped is your solutions:
frameworkElement.SetResourceReference(dependencyProperty, resourceKey);
Last modified: 2010-06-15 21:41:07
Copyright (c) by Christian Moser, 2011.
Comments on this article
Show all comments
|
Tod | |
|
Commented on 8.July 2010 |
owsome
|
|
|
|
Hugo Gu | |
|
Commented on 13.September 2010 |
While, as we can see, this way requires a framework element to work on.
Do you know how to make it on a GridViewColumn? You know, the GridViewColumn is derived from DependencyObject and don't have that SetResourceReference method.
Thank you very much.
|
|
|
|
CyberAngel | |
|
Commented on 4.August 2011 |
Thanks for sharing.
|
|
|
|
|
|