Reputation: 25927
I often write the following code in the XAML:
(...)
xmlns:vs="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.12.0"
(...)
<Path Fill="{DynamicResource {x:Static vs:VsBrushes.GrayText}}">
How can I create such Path
from the codebehind? (precisely: how to attach the DynamicResource to the dependency property?)
Upvotes: 0
Views: 545
Reputation: 3741
I hope this helps: FrameworkElement.SetResourceReference Method
EDIT: in your case it should look like this:
pathObject.SetResourceReference(Path.FillProperty, Microsoft.VisualStudio.Shell.VsBrushes.GrayText);
I don't know why the documentation says that the second parameter should be Object name, it actually accepts the resource Key
.
Upvotes: 1
Reputation: 69959
I can answer half of your question with the FrameworkElement.SetResourceReference
Method:
PathName.SetResourceReference(Path.FillProperty, "NameOfBrush");
However, I'm not quite sure how you'd use your vs:VsBrushes.GrayText Brush
with it.
Upvotes: 1