How do I put a border around an image in WPF?

前端 未结 3 1621
北海茫月
北海茫月 2021-02-05 02:45

I have a StackPanel containing five images and I want to put a black border around each image.

The XAML I have at the moment is:



        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 02:49

    I just stumbled upon this post and the other answer did not work right. Maybe because I now use framework 4 and this post is old?

    In any case - if someone will see this by chance in the future - here is my answer:

     
    
         
    
      
    

    The border thickness and brush are important (if you wont choose a color - you will not see the border!!!)

    Also, the border should be aligned on your window. The image is "inside" the border, so you can use margins or just stretch it like I did.

提交回复
热议问题