Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically resizing a window in Xaml

Is there a way for me to have the Window of my WPF application resize dynamically with the content? I tried setting the width and height to auto, but no go.

like image 219
Matthew Kruskamp Avatar asked Jan 30 '09 18:01

Matthew Kruskamp


People also ask

How do I resize a control in WPF?

In WPF, you can create a resizable shape by using the Path control. Simply set up your shape's path data and then set the Stretch property to Fill and your shape will resize itself to fit the space available. It even takes into account the stroke thickness.

Is WPF scalable?

Because WPF is able to scale your application based on the system DPI, you should avoid using bitmaps in your application. Instead, you should render all controls, e.g. buttons on a toolbar, with vector graphics so that they can be scaled larger/smaller and still look correct.

What is window in XAML?

It is the root window of an XAML application which provides minimize/maximize option, Title bar, border, and close button. It also provides the ability to create, configure, show, and manage the lifetime of windows and dialog boxes.


1 Answers

Set SizeToContent="WidthAndHeight" on the window and the window will dynamically resize based on its content size.

like image 191
Jobi Joy Avatar answered Sep 20 '22 21:09

Jobi Joy