开发者

WPF Resolution Independence [duplicate]

This question already has answers here: Closed 10 years ago.

Possible Duplicate:

C# WPF resolution independancy?

What is the difference between resolution of monitor and System DPI with relation to WPF resolution independence.

Changing what between the two keeps the size of window same in WPF which was earlier not possible in User32?

EDIT: The book I am reading "Pro 开发者_运维知识库WPF in C Sharp" says that if we create a 1 inch button in 96 DPI and then later change the DPI to 120, due to more pixel density, the button would become small (in winforms).But I tried that and I can see that in both the two cases the button size remains the same !

Why is it so ?


Actually, the so-called resolution independence of WPF doesn't enable you to do anything you couldn't do before in Win32. It's just that it was a lot more work before. So the only real change here is one of develop effort - there's no change in the fundamental capabilities. (And that's true of everything in WPF actually. If you have several years of development time to spare, you can do everything WPF does by programming directly against DirectX APIs...)

WPF automatically takes into account the nominal DPI configuration. In Win32, if you want your application to be sensitive to the nominal DPI, you have to write additional code to make that happen, and you have to deal with various horrible layout issues if you want to avoid problems like text getting cropped with some DPIs. (Although now that we have GDI32-style text rendering in .NET 4, you can opt back into all those problems in WPF apps...)

So the answer to your question is essentially: no difference. WPF makes it much easier to take the DPI into account, but it doesn't enable any new behaviour here.

Fundamentally, WPF runs into exactly the same problems as classic Win32 apps for the simple reason that it has access to exactly the same information as classic Win32 apps. As the pages linked to in other answers here discuss, Windows usually has no idea what the DPI really is. Most of the time it'll tell you that the monitor is 96dpi. Well I've got 3 screens attached to my computer, and Windows is reporting 96dpi for all of them, even though none of them is really 96dpi, and they're not even all the same dpi in reality.

The bottom line is: Windows doesn't usually have any idea what the real DPI of your screen is. There's nothing WPF can do to overcome that. If there were a way for WPF to discover the real DPI, Win32 apps would be able to discover it too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜