WPF Units and Code-Behind
Recently I discovered WPF supports different measurement units in XAML. Besides default DIPs, there is also support for pixels, inches and centimeters (as far as I know). This allows designer to write XAML such as this: <Canvas> <Line X1="0cm" X2="3cm" Y1="1cm" Y2="3cm" Stroke="Black"/> </Canvas> However, you cannot bind these values. Imagine we have a ViewModel with Dimension property which is a String, for example "7cm". Following won't work: <Button Width="{Binding Dimension}">Test</Button> FormatException gets thrown. Similarly, when creating a FrameworkElement in code-behind, like this: