Search code examples
wpfuser-controlssizetocontent

Set usercontrol size According to the Controls inside it


hi i want Set usercontrol size According to the Controls inside it how i can do this? long time ago I used the propretis SizeToContent , but I can not find it right now


Solution

  • @zahra_rajabi, Generally setting width and height properties to "Auto" will automatically sets width and height of a container according to its contents.

    Set your main container (width, height) in Usercontrol to Auto to achieve SizeToContent.

    * **Remember: DesignWidth and DesignHeight are usefull only on design time