I’m an experienced C++/Qt developer but a newbie C#/WPF developer, and I’m wondering if I’m missing something with the Visual Studio 2010 WPF designer.
In Qt, all widgets have a parent. I found this concept very useful both when building GUI programmatically and in the designer. From what I remember from Qt desginer (unfortunately my new company doesn’t support Qt), you could easily drag widgets around and they get re-parented correctly. If the designer somehow got confused, then you could just reset the parent to whatever you needed in the properties box. I find the analogous ideas in WPF difficult to execute.
In the Visual Studio Designer, when I drag widgets around, they only sometimes get the right parent. More often than not, I have to go to the xaml and cut-and-paste the widget I was writing into a different part of the xaml so that it gets the right parent. I understand that the DOM tree of xaml nicely parallels the widget parent tree, but I found that was much more explicit in Qt.
So, my question is: is this cut-and-paste approach to re-parenting in WPF xaml the best you can do or are there some nice designer tips-and-tricks that I am missing?
Note: this question obviously doesn’t apply when building GUI programmatically.
In my experience this boils down to a lacking designer in VS2010. Personally I use the designer for WPF as a view on how the GUI will look, and then hand code most of my XAML. I almost never actually DO anything in the designer such as drag an element or such.
To answer your question, the cut-paste in xaml approach you mention is in my experience the most efficient way to “re-parenting” elements.