Neha
Neha

Reputation: 821

Why System.Windows.FrameworkElement uses double type for properties like width and height?

Application.Current.MainWindow.Height

is a double type property defined in FrameworkElement . We could have used integer type as well,as screen resolutions are mostly integer types e.g, 480x600 . What can be the reason behind taking double type property?

Upvotes: 2

Views: 209

Answers (1)

Moby Disk
Moby Disk

Reputation: 3861

WPF units are not pixels. The unit is 1/96th of an inch. So a thickness of 1 is not necessarily 1 pixel. It would only be 1 pixel if it was rendered to a display set to 96 dpi. But a printer, or a screen that has a higher DPI, it might be multiple pixels. Also, you can use fractional widths and it will anti-alias.

Take a look at the documentation for Thickness: http://msdn.microsoft.com/en-us/library/system.windows.thickness%28v=vs.110%29.aspx

Upvotes: 2

Related Questions