Closed JoshWobbles closed 5 years ago
not sure whats the best way, and I‘ve no time atm. best would be if you implement it diretc in wpf designer sourcecode, and when it works we look what changes we need in the original classes
What type is the native dragdrop functionality expecting? Perhaps I can simply reset the data property on drag enter.
Or, how to I create an element in the design panel from code behind?
object newInstance = designSurface.DesignContext.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory(typeof(Image), null);
DesignItem item = designSurface.DesignContext.Services.Component.RegisterComponentForDesigner(newInstance);
designSurface.DesignContext.RootItem.ContentProperty.CollectionElements.Add(item);
This seems to work, but I am not sure it is the preferred method of doing so.
Or, how to I create an element in the design panel from code behind?
object newInstance = designSurface.DesignContext.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory(typeof(Image), null); DesignItem item = designSurface.DesignContext.Services.Component.RegisterComponentForDesigner(newInstance); designSurface.DesignContext.RootItem.ContentProperty.CollectionElements.Add(item);
This seems to work, but I am not sure it is the preferred method of doing so.
I would change the first line to
var newInstance = new Image()
The rest is fine.
But I also would open a new ChangeGroup before
var cg = designSurface.DesignContext.RootElement.OpenGroup("aa");
and commit the group when finished. so that undo is possible
does it work?
Not the best solution, I'd still like to hook into the inbuilt drop support so content can be dropped in containers and not just the root grid, but its much better than nothing.
I‘ll look
can you look at my last commit?
Ill take a look, thanks! Any ides on this one; https://github.com/icsharpcode/WpfDesigner/issues/57 ? I haven't had much luck working around it on my end yet
no, I could not reproduce it.
couldn't you create a simple sample app? I tried in xamldesigner sample with mediaelement and autoplay, it works
would compiled app and pdb's be enough? Also, keep in mind, the issue does not present until the xaml is serialized then deserialized back into the designer, leading me to believe that the issue could be in the way xaml is parsed in.
try to add a MediaElement to the Demo.XamlDesigner App. Then switch to xaml code and back to design. It works
Don't know if I could help you when you give me the compiled app + pdb's
Unfortunately it doesn't work, I still get the error when a video is loaded in it, using the demo here or creating a new bare bone app all result in the same error. I posted back in the original issue my code and the XAML i am trying to load, try pointing the source to a local video of yours and see if it loads. then
What about the DragDrop Helper? Is this usefull?
Still tinkering, I get some pretty odd and erratic behavior on margin and alignment properties and I cant seem to override them, I have a feeling that may all be tied to the move/resize etc controls that are baked into the designer, because they can behave oddly at times too.
From what I can tell there is already a bunch of support in place for drag and drop functionality. I would like to expand on this for the purpose of being able to drag a file, such as a jpg, onto the design surface and have it create an Image element with the source set to my dragged file.
Due to protection levels of a couple sealed classes I am unable to just "overrule" the current drag-drop functionality, so how would I go about this?