Archives / 2010 / January
  • Set the MinWidth and MinHeight based on SizeToContent Property

    We are developing a WPF application for a client where they want to be able to use the SizeToContent=”WidthAndHeight” attribute on the window. This attribute is great because it allows WPF to size the window to the size of the controls on the window. This is especially important as they need the labels to grow and shrink when they localize the labels for English, Spanish and German. Once the initial size is set by WPF, they want that initial size to be the minimum height and minimum width for that window. As it turns out, this is very easy to accomplish in WPF.

  • Centering Text within a WPF Shape using a Canvas

    In my last blog post, I showed you how to use a Shape control, a Border control and a TextBlock to create rectangles, circles, ellipsis, and triangles with text in the middle of the shape. You also learned how to use a VisualBrush in a TextBlock to help you center the text as well. In this post, you will learn another technique for accomplishing the same task. This blog will show you how to use a Canvas, a Shape and a TextBlock. The reason for using a Canvas is to introduce you to using a Multi-Binding converter in WPF.

Past Blog Content

Blog Archive