Reusable Custom Content for Buttons

后端 未结 3 1624
无人及你
无人及你 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:42

    The easiest thing to do is create a UserControl for this:

    1. Create a UserControl
    2. Add a "ImageSource" dependency property to the UserControl class of type BitmapSource for the image
    3. Add a "Text" dependency property to the UserControl class of type string
    4. For your UserControl XAML, put the following XAML (simplified for brevity, you can change to suit your layout needs)

    XAML for UserControl:

    
        
    
    

    Now you can reuse your user control wherever you want like so:

    
    

提交回复
热议问题