You may want to have a look at MyXAML source code for help and ideas
(
www.myxaml.com.) The project author gave me some tips/pointers to help me
with my designer host project. Unfortunately, I haven't found much about
designer host technologies, etc. on the internet either. I even posted a my
designer host issues on experts exchange but received no replies after 30
days, so I pulled the question.
Don't know if this will be useful, but here is a little bit about what I did
with the MS sample designer host app:
I have used Microsoft's example for a "custom dialog generator" project and
had issues with serialization, but my issues are unrelated to the issues you
identify here. I attempted to add custom controls where I could hide many
control properties from the PropertyGrid control. In doing so, I had issues
with serialization, especially where my custom controls included new
(extended properties), etc. The key to making things work correctly in the
end was properly adding attributes for serialization, etc. to my extended
properties in a wrapper class. I ended-up turning the sample designer host
solution into a DLL (not too hard to do.) I utilize the sample's generate
code methods to get the layout details in XML format. I then parse the form
and control properties into a custom, serializable class which contains
extended properties the user can set; e.g. button click behaviors, etc. I
serlialize my custom class into XML. This XML can then be used directly via
my rendering engine to create custom dialogs or forms.
[quoted text, click to view] "Sergey M" wrote:
> Hi all,
>
> We have a custom form designer that is based on Microsoft's sample
> available for download. There were few things missing in that sample
> that we've added:
> - IExtenderListService implementation for site class
> - GetExtenderProviders() for site class that calls into class host
> - our own design form, which is declared as: DesignForm : Form, with
> the following attribute:
> Designer("DesignerHost.Designers.DesignFormDesigner,
> DesignerHost.Designers", typeof(IRootDesigner))
> - our own form designer declared as DesignFormDesigner :
> DocumentDesigner
>
> Everything seems to work fine except serialization. It appears that
> most of the newly created design form properties simply don't
> serialize. After some extensive research we found the cause of the
> problem, which appears to lie in Microsoft's design support classes.
> Here's what happens:
> - When our form designer is created, it calls into base.Initialize(),
> which is followed by PreFilterProperties()/PostFilterProperties()
> calls while it's still in base.Initialize()
> - Right after those 2 calls DocumentDesigner().Initialize() adds 3
> designer extenders (LocalizationExtenderProvider, etc.) to the site
> - Next call to TypeDescriptor.GetProperties() for our designer
> component fails to find previouselly cached component type reference
> in its cache because number of extender providers is taken into
> account when performing cache lookups (that's due to the previous item
> I've just mentioned)!
> - The above TypeDescriptor.GetProperties() resolution failure causes
> our ITypeDescriptorFilterService.FilterProperties() implementation to
> be called, which in turn calls into our designer
> PreFilterProperties()/PostFilterProperties() for the 2nd time!
> - That eventually calls into ComponentDesigner.PostFilterProperties(),
> which swaps most of the cached properties types from
> ReflectPropertyDescriptor to InheritedPropertyDescriptor
> - During serialization,
> InheritedPropertyDescriptor.ShouldSerializeValue() acts slightly
> differently from ReflectPropertyDescriptor.ShouldSerializeValue(), but
> enough to reject the value changes as not required serialization,
> hence the problem
>
> This is rather an advanced subject and I wouldn't be surprised if I
> don't get many replies. I hope this makes sense and that good people
> at Microsoft will be able to shed some light on it. I'd appreciate any
> suggestions at this point. Thanks.
>
> PS We use VS.NET 2003.
> --
> Sergey Mishkovskiy
>
http://www.usysware.com/dpack/ - DPack - free VS.NET add-ons
>
http://www.usysware.com/blog/ >
>
>