Reusable Custom Content for Buttons

后端 未结 3 1626
无人及你
无人及你 2021-01-15 23:32

My user interface makes use of customized Buttons: They contain both an Image and a Label.

I customized a single Button

3条回答
  •  囚心锁ツ
    2021-01-15 23:40

    you could:

    1. Derive a class from button, add the two properties and overide the control template. using a usercontrol that contains the button you will be forced to do work arounds such as exposing the button as a property. (to attach commands, get the click event etc.)

    2. create your own straight class that has the two properties, and set it to be the buttons content, and create a data template for it, then the button stays as a straight button. If you want these properties to be set from the xaml, derive from control or something that allows dependency properties

    I would use the second approach, its simple, and quick.

提交回复
热议问题