0

If I have a custom control and, for example, it's composed of 3 buttons. Each of the buttons is named in the Control Contract like so: Part_Button1, Part_Button2, Part_Button3.

How would I apply a style to this control in my view where I only modify the style of a single button? Do I have to supply a new control template for the entire control, with each of the parts re-defined?

Sam
  • 1,325
  • 1
  • 13
  • 26
  • Possible duplicate of [How do I Access Buttons inside a UserControl from xaml?](https://stackoverflow.com/questions/39886903/how-do-i-access-buttons-inside-a-usercontrol-from-xaml) – ASh May 19 '18 at 18:50
  • @ASh This is a "Custom Control," not a "UserControl" though. I know that has some styling implications. – Sam May 20 '18 at 19:10
  • 1
    @Sam So you're saying the answer is affected by the exact details of the secret code that you won't show anybody. OK. Anyway, give the custom control a dependency property of type `Style`, and use a TemplateBinding to bind that to the button's Style property in the control template. – 15ee8f99-57ff-4f92-890c-b56153 May 21 '18 at 14:32
  • 1
    That's essentially [what's suggested in ASh's answer](https://stackoverflow.com/a/40083454/424129) to that question -- the only thing that differs is the type of binding. All of the other answers there, including the accepted one, range from terrible to unintelligible. – 15ee8f99-57ff-4f92-890c-b56153 May 21 '18 at 14:37

0 Answers0