7

Instead of most of you guys who first learned Winforms then moved to WPF, I'm the opposite! For some reasons regarding the graphic performance I have to use Winforms. But I'm stuck at the first step. How can I make the UI responsive like WPF. What is the equivalent of Grids in Winforms. Any help is highly appreciated.

Vahid
  • 5,144
  • 13
  • 70
  • 146
  • 4
    As this stands, the question is too broad. Please ask the Grids part as another question, and explain exactly what you mean by responsive. Perhaps give some sample code which leads to "unresponsive" UI, and tell us how this performs, and what performance you were expecting. – Chris Ballard Mar 24 '14 at 10:42
  • @ChrisBallard Actually I asked the question regarding performance but nobody answered, I don't want to go to Winforms in my heart but I'm really stuck. http://stackoverflow.com/questions/22551841/building-a-cad-program-in-wpf – Vahid Mar 24 '14 at 10:46
  • Strange, I always thought that you either use the graphic-accelerated WPF or DirectX. But frankly I don't think that WinForms/GDI+ has faster graphics rendering than WPF. – grizzly Mar 24 '14 at 10:48
  • 1
    Winforms typically is faster than WPF, but it really depends what you are trying to do. Winforms UI is generally _much_ simpler than WPF, hence better perf. If you are trying to make Winforms look like WPF you may be getting into trouble there. Please post some code. – Chris Ballard Mar 24 '14 at 10:49
  • I don't have any code in Winforms, I'm new at this. I was trying to build a CAD program in WPF but the performance is terrible for this kind of stuff. – Vahid Mar 24 '14 at 10:52
  • I think this question was about how to make a "dynamic layout" in winforms, similar to what "responsive ui" means in web development? It seems it got closed for a wrong reason. – vgru May 26 '17 at 07:42

2 Answers2

7

If by responsive you mean working on all screen resolutions, you can use panels, and dock controls inside. With a correct mix of controls docked in panels, docked in the main form, you can get a nice design which will automatically fit on all screens. You can also use Anchor property to make a control "stick" to for example top right corner(by default it's always top-left). At least that's what I understood from your question.

vfioox
  • 730
  • 1
  • 8
  • 22
5

Another option would be using WPF for all your controls and layouting, and then use winforms host in WPF for your CAD application, you will have the benefits of WPF for responsiveness and you will get the performance for drawing with winforms.

woutervs
  • 1,500
  • 12
  • 28
  • Is this possible. This maybe the exact right choice for the current scenario I have. Please see my other link regarding the reason I've come to to choose Winforms over WPF.http://stackoverflow.com/questions/22551841/building-a-cad-program-in-wpf – Vahid Mar 24 '14 at 10:57
  • 1
    https://www.simple-talk.com/dotnet/.net-framework/mixing-wpf-and-winforms/ This might help you out deciding wheter or not it would work for your specific scenario. But in my opinion this looks like the best approach to have the best of both worlds. – woutervs Mar 24 '14 at 11:05