Bashir Magomedov
Bashir Magomedov

Reputation: 2891

ControlTemplate.Resources in a code-behind file

How can I get a named resource from ControlTemplate in a code-behind file (*.xaml.cs)? TryFindResource returns null. Template property of the control is also null. What else should I try? Thanks.

Upvotes: 0

Views: 1442

Answers (1)

viky
viky

Reputation: 17679

Are you using custom control? If yes, you can override OnApplyTemplate method in custom control and can use Template.Find("name of resource") then expose it as a property from the control.

if No, then use custom control.

Hope it helps!

Upvotes: 1

Related Questions