Table of Contents

WPF Form Designer

WPF Form Designer provides a design-time surface where the user can place controls from the toolbox, arrange them, examine and change their properties and write event handlers for their events.

FormDesignerControl Control

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl> is based on SharpDevelop open-source FormDesigner package: https://github.com/icsharpcode/WpfDesigner

FormDesigner

Below are the essential properties, methods, and events of FormDesignerControl class:

Properties:

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.DesignerCommands> - provides an interface to Form Designer commands, such as Copy/Paste, Undo/Redo, Aligning and Arranging controls, etc.

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.IsModified> - Indicates whether designer content has been modified since the last save.

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.SelectedItems> - contains a list of selected controls.

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.Source> - gets or sets FormDesigner Source.

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.ReferencedAssemblies> - gets a collection of assemblies where the controls used on the form being designed are declared.

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.CurrentTool> - gets or sets the currently selected tool in the Form Designer.

Events:

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.NavigateToUserMethodRequested> - occurs when the form designer is requested to navigate to the event handler. For example, when a user double-clicks on the control.

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.SelectionChanged> - occurs when a user selects a different control in the designer.

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.DesignedContentChanged> - occurs when a user modifies any aspect of the control being designed.

Methods:

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.Reload> - reloads form to be designed from the source.

<xref:Alternet.FormDesigner.Wpf.FormDesignerControl.Save> - serializes designer content to the XAML code.

Form Designer works with two different source files simultaneously: XAML containing design-time code and C# or Visual Basic source containing user-written event handlers. Most often, users will need to edit a file containing event handlers, which will require setting up FormDesignerControl control's source to the one supporting integration with the editor. Refer to FormDesignerTextSource class for the implementation of the source, which integrates with TextEditor control included in our demo projects.

Error Handling

WinForms FormDesigner loads and saves its content into C#/VisualBasic, Python, or TypeScript/JavaScript code; this code needs to be correct both from a syntax and semantic point of view. If the FormDesigner loader encounters an error in the code, it switches to error mode. It displays a list of found errors, allowing a user to click and navigate to the error source by handling CompilerErrorClick event.

ToolboxControl

The <xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl> control displays components and controls you can place onto the design surface. It provides a set of foldable tabs helping to organize controls by categories and allowing to specify which components and controls, including third-party controls, appear on the toolbox, on which tabs, and sort order.

ToolboxControl

ToolBox control can be linked to <xref:Alternet.FormDesigner.Wpf.FormDesignerControl> by setting <xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.FormDesigner> property which allows dragging components and controls to the Form Designer.

Below are essential properties and methods to manipulate Toolbox control:

Properties

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.CategoryNames> - gets a collection of Categories (Tabs) displayed by the toolbox.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.SelectedToolboxItem> - returns the currently selected toolbox item.

Methods

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.AddCategory*> - adds a new category to the toolbox.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.AddItem*> - places a toolbox item onto the specified toolbox tab.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.ClearItemsInCategory*> - clears items in the specified tab.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.GetAllTools> - gets all toolbox items.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.GetToolsFromCategory*> - gets toolbox items on the specific tab.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.SelectPointer> - deselects currently selected toolbox item and selects pointer tool.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.RemoveCategory*> - removes a specific tab.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.RemoveItem*> - removes a toolbox item from the category.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.SetSelectedItem*> - selects toolbox item.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.AddItemForType*> - adds toolbox item from the type name.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.AddItemsFromAssembly*> - add all types that can appear on the toolbox from the assembly.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.BeginUpdate> - prevents repainting of the toolbox until EndUpdate is called.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.EndUpdate> - re-enables toolbox repainting.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.Save*> - saves the toolbox content to the specified stream.

<xref:Alternet.FormDesigner.Wpf.Toolbox.ToolboxControl.Load*> - loads the toolbox content from the specified stream.

PropertyGridControl

The <xref:Alternet.FormDesigner.Wpf.PropertyGrid.PropertyGridControl> control allows the user to view and change the design-time properties and events of the selected controls or components.

PropertyGridControl

PropertyGrid control can be linked to <xref:Alternet.FormDesigner.Wpf.FormDesignerControl> by setting FormDesignerControl property allows viewing and changing properties and events for the controls selected in the Form Designer.

OutlineControl

OutlineControl displays the form's layout as a tree view, providing an easy way to navigate, show/hide and re-arrange controls on the form.

OutlineControl

OutlineControlcontrol can be linked to <xref:Alternet.FormDesigner.Wpf.FormDesignerControl> by setting <xref:Alternet.FormDesigner.Wpf.Outline.OutlineControl.FormDesigner> property which allows navigating through the controls displayed by the Form Designer.