Back to Devexpress

ReportDesigner.RegisterControl<T>(Func<XRDiagramItem>, ImageSource, Func<XRDiagramControl, Size>) Method

wpf-devexpress-dot-xpf-dot-reports-dot-userdesigner-dot-reportdesigner-dot-registercontrol-t-x28-func-xrdiagramitem-imagesource-func-xrdiagramcontrol-size-x29.md

latest8.1 KB
Original Source

ReportDesigner.RegisterControl<T>(Func<XRDiagramItem>, ImageSource, Func<XRDiagramControl, Size>) Method

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

Declaration

csharp
public static void RegisterControl<T>(
    Func<XRDiagramItem> createItem,
    ImageSource icon,
    Func<XRDiagramControl, Size> getDefaultSizeFunc = null
)
    where T : XRControl, new()
vb
Public Shared Sub RegisterControl(Of T As {XRControl, New})(
    createItem As Func(Of XRDiagramItem),
    icon As ImageSource,
    getDefaultSizeFunc As Func(Of XRDiagramControl, Size) = Nothing
)

Parameters

NameTypeDescription
createItemFunc<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.

|

Optional Parameters

NameTypeDefaultDescription
getDefaultSizeFuncFunc<DevExpress.Xpf.Reports.UserDesigner.XRDiagram.XRDiagramControl, Size>null

A function that returns the default item size.

|

Type Parameters

Name
T

Remarks

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.

csharp
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);
vb
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

csharp
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

csharp
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

vb
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

vb
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

Use Custom Controls

Create a Custom Control Inherited From XRControl

ReportDesigner Class

ReportDesigner Members

DevExpress.Xpf.Reports.UserDesigner Namespace