wpf-devexpress-dot-xpf-dot-reports-dot-userdesigner-dot-reportdesigner-dot-registercontrol-t-x28-func-xrdiagramitem-imagesource-func-xrdiagramcontrol-size-x29.md
Registers a custom control in the Report Designer and adds it to the Toolbox.
Namespace : DevExpress.Xpf.Reports.UserDesigner
Assembly : DevExpress.Xpf.ReportDesigner.v25.2.dll
NuGet Package : DevExpress.Wpf.Reporting
public static void RegisterControl<T>(
Func<XRDiagramItem> createItem,
ImageSource icon,
Func<XRDiagramControl, Size> getDefaultSizeFunc = null
)
where T : XRControl, new()
Public Shared Sub RegisterControl(Of T As {XRControl, New})(
createItem As Func(Of XRDiagramItem),
icon As ImageSource,
getDefaultSizeFunc As Func(Of XRDiagramControl, Size) = Nothing
)
| Name | Type | Description |
|---|---|---|
| createItem | Func<DevExpress.Xpf.Reports.UserDesigner.XRDiagram.XRDiagramItem> |
A function that returns a diagram item corresponding to the custom control.
| | icon | ImageSource |
An object that specifies an icon for the custom control.
|
| Name | Type | Default | Description |
|---|---|---|---|
| getDefaultSizeFunc | Func<DevExpress.Xpf.Reports.UserDesigner.XRDiagram.XRDiagramControl, Size> | null |
A function that returns the default item size.
|
| Name |
|---|
| T |
The following example demonstrates how to add a Progress Bar custom control to the Report Designer‘s toolbox using the RegisterControl<T> method. To learn more, see Adding a Custom Control to the Report Designer Toolbox.
Tip
A complete sample project is available in the DevExpress Code Examples database at https://supportcenter.devexpress.com/ticket/details/t416384/reporting-for-wpf-how-to-register-a-custom-control-in-the-designer-s-toolbox.
using DevExpress.Utils;
using DevExpress.Xpf.Reports.UserDesigner;
using DevExpress.Xpf.Reports.UserDesigner.XRDiagram;
using System.Windows.Media.Imaging;
//...
var icon = BitmapFrame.Create(AssemblyHelper.GetResourceUri(GetType().Assembly, "progress.png"));
ReportDesigner.RegisterControl<XRProgressBar>(() => new DefaultXRControlDiagramItem(), icon);
Imports DevExpress.Utils
Imports DevExpress.Xpf.Reports.UserDesigner
Imports DevExpress.Xpf.Reports.UserDesigner.XRDiagram
Imports System.Windows.Media.Imaging
'...
Dim icon = BitmapFrame.Create(AssemblyHelper.GetResourceUri(GetType.Assembly, "progress.png"))
ReportDesigner.RegisterControl(Of XRProgressBar)(Function() New DefaultXRControlDiagramItem(), icon)
For information on creating custom controls, see the Creating Custom Controls, Creating a Custom Progress Bar Control and Creating a Custom Numeric Label documents.
The following code snippets (auto-collected from DevExpress Examples) contain references to the RegisterControl<T>(Func<XRDiagramItem>, ImageSource, Func<XRDiagramControl, Size>) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
wpf-reporting-register-custom-control-in-designer/CS/MainWindow.xaml.cs#L18
var icon = BitmapFrame.Create(AssemblyHelper.GetResourceUri(GetType().Assembly, "progress.png"));
ReportDesigner.RegisterControl<XRProgressBar>(() => new DefaultXRControlDiagramItem(), icon);
}
reporting-wpf-report-designer-customize-controls-smart-tag/CS/MainWindow.xaml.cs#L20
var icon = BitmapFrame.Create(AssemblyHelper.GetResourceUri(GetType().Assembly, "progress.png"));
DevExpress.Xpf.Reports.UserDesigner.ReportDesigner.RegisterControl<XRProgressBar>(() => new XRProgressBarDiagramItem(false), icon);
reportDesigner.OpenDocument(new XtraReport1());
wpf-reporting-register-custom-control-in-designer/VB/MainWindow.xaml.vb#L20
Dim icon_Renamed = BitmapFrame.Create(AssemblyHelper.GetResourceUri(Me.GetType().Assembly, "progress.png"))
DevExpress.Xpf.Reports.UserDesigner.ReportDesigner.RegisterControl(Of XRProgressBar)(Function() New DefaultXRControlDiagramItem(), icon_Renamed)
End Sub
reporting-wpf-report-designer-customize-controls-smart-tag/VB/MainWindow.xaml.vb#L23
Dim icon_Renamed = BitmapFrame.Create(AssemblyHelper.GetResourceUri(Me.GetType().Assembly, "progress.png"))
DevExpress.Xpf.Reports.UserDesigner.ReportDesigner.RegisterControl(Of XRProgressBar)(Function() New XRProgressBarDiagramItem(False), icon_Renamed)
reportDesigner.OpenDocument(New XtraReport1())
See Also
Add a Custom Control to the Report Designer Toolbox