How to set WPF Window's width equal to the content in its Title Bar?

前端 未结 1 1699
挽巷
挽巷 2020-12-21 04:15

If I have Window in WPF as follows:



        
1条回答
  •  温柔的废话
    2020-12-21 04:33

    Add a hidden textblock in to the window:

    
    
    

    The Margin allows for the windows controls to be pushed out of the way.

    The Height makes the control take up no vertical space.

    The Visiblity is probable not required because of the zero height, but by setting it to hidden will cause it to take up space on the canvas but show nothing.

    0 讨论(0)
提交回复
热议问题