I am considering to use XamDiagram as UI designer control.
Visualy it should work similar to XAML UI designer in Visual Studio.
My app should be able to :
- drag & drop controls to canvas (like button, input, dropdown, image...)
- move, resize, copy... controls in canvas
- configure controls, for example when I place dropdown to canvas I should be able to enter items to be displayed in this dropdown
- export my designed UI to DB or XML or whatever
- load exported data parse them and generate real UI on runtime
Do you think that using XamDiagram is the right choice? Or it was not intened for this purpose?
Thanks
Hello Alan A,
My team and I have done an initial review of this thread, and while the XamDiagram wasn’t exactly designed for this purpose as it was designed to be more of a “workflow diagram”, I believe it is the closest thing in the Infragistics for WPF toolset that would help you to create the behavior you are seeing. Below I will address each of the points that you have provided with an explanation of how I think you might be able to achieve it:
Drag & drop controls to canvas (like button, input, dropdown, image...): This may be possible if you add a custom toolbox item to the existing XamDiagramToolbox control. You can read about the XamDiagramToolbox at the following documentation article: https://www.infragistics.com/help/wpf/xamdiagram-configuring-the-toolbox. In the sample code-snippet, there is an example of how to add a DiagramToolboxItem that contains a DiagramNode that is then given a path. Instead of giving this a path, you would need to modify the DiagramNode’s Template property such that it looks like a Button, Input, DropDown, or other control as the nodes will not look this way by default. This would most easily be done by modifying the default template of the DiagramNode, which exists in the generic.xaml file commonly found at the following directory when Infragistics controls are installed:
C:\Program Files (x86)\Infragistics\<version>\WPF\DefaultStyles\XamDiagram
Move, resize, copy... controls in canvas: This is built-in to the XamDiagram control. You can move, resize, and copy nodes within the canvas of the XamDiagram.
Configure controls: This could potentially be difficult, but if you could somehow have your node have a reference to the control that it is displaying, you could utilize the XamPropertyGrid to modify the properties of that node, much like the Properties window in the Visual Studio designer. You can read further about the XamPropertyGrid here: https://www.infragistics.com/help/wpf/xampropertygrid.
Then, you could utilize the SelectionChanged event of the XamDiagram to find out which item (or items) you have selected and push the item to the SelectedObject property of the XamPropertyGrid for modification.
Export my designed UI / Load exported data parse them and generate real UI on runtime: Regarding these pieces, there is nothing built-in to the XamDiagram that would allow you to do this. The best way I can recommend to do this would be to loop through the XamDiagram.Items collection, as this would return you the nodes that are placed in the XamDiagram and you could use the information that you provide about those nodes to generate an exported UI for your database or an XML file. At that point, the loading and how this database or XML file is read would be up to you as well.
Please let me know if you have any other questions or concerns on this matter.
Hello Andrew, thanks for your answer.
I have make also some small investigation and I would have to override (change behavior) a lot of build-in core functionalities to meet my customer requirements. For example I would have to override Drag/Drop, Move/Resize, Undo/Redo, Selection, Tab order, Z-Index... Also Copy/Paste functionality would have to support copy/paste for configured properties of controls (not only shape). Multi-select also have to support resizing ...
I would like to know whether you can recommend using highly customized XamDiagram as UI designer component. Is there a guarantee that my highly customized changes of core behavior will not be affected by next releases/bug-fixes of XamDiagram?
Many thanks for answer.
Thank you for your update on this matter.
It definitely sounds like this would be very complicated, but if there is a control that I would recommend to create a UI designer component in the Infragistics for WPF toolset, it would have to be the XamDiagram, as that is the closest thing that we have to a “drag and drop drawing Canvas” type of control.
As for future releases and bug-fixes of the XamDiagram affecting your customized changes, it really depends on the changes you make and how they are made and what the bug fixes are. There is no guarantee that I can 100% make that future releases and bug fixes will not affect the functionality that you are doing, especially if you are using things like reflection to get into the private APIs of the control.