0

I want to add a trigger to a ControlTemplate. That's it. I don't want to override any of the control. I thought the ContentPresenter did this. But instead it replaces my button with text that says "FOO". I only have this so I can add a ControlTemplate trigger. How dfoes ContentPresenter work? Do I instead need to add another button inside this? Seems wrong since that button would not be styled correctly.

<Button Width="24" Height="24" Content="FOO">
   <Button.Template>
      <ControlTemplate TargetType="Button">
         <ContentPresenter />
      </ControlTemplate>
   </Button.Template>
</Button>
Paul
  • 5,700
  • 5
  • 43
  • 67
  • 3
    You cannot replace just a part of a `ControlTemplate` (see http://stackoverflow.com/questions/2221187/replace-part-of-default-template-in-wpf for details). Please explain what the trigger shall do that you want to add; maybe there is another way to accomplish that. –  Jun 18 '14 at 20:13
  • 3
    I guess you're looking for `Style.Triggers`? Please explain why you want to do this. – Federico Berasategui Jun 18 '14 at 20:20
  • The Button.Click event was going to have a Storyboard in it. That's all I was wanting to do. – Paul Jun 18 '14 at 20:29
  • 2
    To run `StoryBoard` you don't even need `Style`. Each `FrameworkElement` has [`Triggers`](http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.triggers.aspx) where you can specify `EventTrigger` and run your `Storyboard` – dkozl Jun 18 '14 at 20:37
  • Yes, sorry. Stupid mistake. Been a while since I've used WPF. Thank you. – Paul Jun 18 '14 at 20:38

0 Answers0