Button template with image and text in wpf

后端 未结 7 848
刺人心
刺人心 2020-12-06 00:59

I want to create buttons with images and text inside. For example, i would use different images and text for buttons like \'Browse folders\' and \'Import\'.

One of th

7条回答
  •  半阙折子戏
    2020-12-06 02:03

    No. What would you bind the Image.Source to? You need a DependencyProperty for this. Of course, you could also define a normal class which contains two properties: Text and ImageSource or Uri, and then use a DataTemplate to render instances of this class, but that would be even more code to write, and it is a little "smelly".

    What is the reason you do not want to use a dependency property or a custom class?

提交回复
热议问题