icsharpcode / WpfDesigner

The WPF Designer from SharpDevelop
MIT License
949 stars 251 forks source link

Way to render custom UserControl #68

Closed Thaval closed 3 years ago

Thaval commented 3 years ago

Hi,

is there a way to render custom UserControls? I experience the problem that there won't be thrown an exception when wrapping for example a "Grid" within a "UserControl" but it's not displayed in the designer. Whenever I remove the UserControl, so the Grid is the root element, then the grid and it's button content will be rendered/displayed.

jogibear9988 commented 3 years ago

What is you root Element in xaml? UserControl class or a special UserControl class you created. If so, is the DLL defining this class also referenced?

Thaval commented 3 years ago

Got it working after hours of researching. The problems I had existed because I thought the XamlReader can handle a default WPF Xaml, but it can't.

My root element is "UserControl". I read some articles and removed the x:Class respectively as it seems that the XamlReader does only support loose xaml (always the typical Microsoft half-way solutions...). However, before passing the Xaml to the DesignerSurface, I manipulate the Xaml:

Seems fine for now. I'm pretty sure I will need to adjust a lot of stuff, but currently I'm fighting with AvalonEdit.