Skip to main content

Microsoft Silverlight

Custom button ovverrides OnClickRSS Feed

(0)

MurDoGG
MurDoGG

Member

Member

12 points

28 Posts

Custom button ovverrides OnClick

Hi guys,

  I generate buttons in code behind, don't know what to preform at develope time so i have to choose at runtime. So my idea was to create a new button control inherits the UIElement.Button and override OnClick event with my own EventHandlerArguments, so i can pass data to the event handler and choose there at runtime what to do, dependent at the data in my own EventHandlerArguments.

Have somebody i idea how to implement or know a best practise to do what i want. Use onClick event with my own EventArgs?!

Thanks for your help. 

Mfg 

MurDoGG

jay nanavati
jay nana...

Contributor

Contributor

3388 points

624 Posts

Re: Custom button ovverrides OnClick

 Create a custom control that inherits from Button and overrides its Click event.

for creating custom control:

 http://www.silverlightshow.net/items/Creating-a-Silverlight-Custom-Control-The-Basics.aspx

for creating custom event args:

http://silverlight.net/forums/t/7756.aspx

 

Jay K Nanavaty
www.technologyopinion.com
Mark as answer if it helps. It will also help others...

MurDoGG
MurDoGG

Member

Member

12 points

28 Posts

Re: Custom button ovverrides OnClick

Thx for your response, think i have found a possibilty to do what i want. I i think i don't need t override OnClick. I inherited from Button and add a property, which i set in Constructor. And in the RoutetdEventHandler i get this property and make my choice what to do.

 Perhaps, but i don't rely know, the Action<T> class could help in this scenarios?

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities