1

I'm designing a custom form in a WPF ResourceDictionary using a controltemplate so I can easily use the window later on. I'm designing it with Expression Blend and I'm stuck on getting the close, maximize and minimize buttons to work.

At first I wasn't able to access any of the events, however this stackoverflow question helped me with binding a class to the resourcedictionary. When I try to access the click event for the close, min and max buttons, I get in the code editor and the btn_Close eventhandler shows up.

When I try to compile it gives me the error "application.Resources doesn't contain a defition for close (...)" (Resources is the name of the class) (when I type "this." intellisense gives me many commands but not .Close)

I'm pretty sure all of the namespaces in both the class and XAML are right, how do I get this working properly? Or do I need to code this seperately for each form that uses this template?

Community
  • 1
  • 1
Nick
  • 51
  • 3
  • Why dont you have a look at [This][1] [1]: http://stackoverflow.com/questions/6792275/how-to-create-custom-window-chrome-in-wpf – Nadeem Shaikh Aug 25 '15 at 11:36

1 Answers1

0

In the strange situation you've arranged, this in the code-behind does not refer to a Window but to the ResourceDictionary. Nevertheless, the event when it occurs will be generated by a window so instead of using this you need to cast the sender parameter to a Window and Close that instead.

Rick Sladkey
  • 33,988
  • 6
  • 71
  • 95