Back to Devexpress

ReportDesigner.RegisterControl<T>(ImageSource) Method

wpf-devexpress-dot-xpf-dot-reports-dot-userdesigner-dot-reportdesigner-dot-registercontrol-1-x28-system-dot-windows-dot-media-dot-imagesource-x29.md

latest4.0 KB
Original Source

ReportDesigner.RegisterControl<T>(ImageSource) Method

Registers a custom control with a specified icon 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>(
    ImageSource icon
)
    where T : XRControl, new()
vb
Public Shared Sub RegisterControl(Of T As {XRControl, New})(
    icon As ImageSource
)

Parameters

NameTypeDescription
iconImageSource

An image source of a control’s icon.

|

Type Parameters

NameDescription
T

The control’s type.

|

Remarks

The following example registers a custom control with a specified icon in the Report Designer. This control appears in the Toolbox.

Tip

To use a predefined icon (or an icon from an assembly) for a custom control, call the RegisterControl<T>() method instead.

csharp
using DevExpress.Xpf.Core.Native;
using DevExpress.Xpf.Reports.UserDesigner;
using DevExpress.XtraReports.UI;
using System.Windows;
using System.Windows.Media;
//...

public class ProgressBar : XRControl { /* ... */ }
//...

public partial class MainWindow : Window {
    public MainWindow() {
        InitializeComponent();

        ImageSource icon = WpfSvgRenderer.CreateImageSource(new Uri("path/to/progress_bar.svg"));
        ReportDesigner.RegisterControl<ProgressBar>(icon);
    }

    private void Window_Loaded(object sender, RoutedEventArgs e) {
        reportDesigner.OpenDocument(new XtraReport());
    }
}
vb
Imports DevExpress.Xpf.Core.Native
Imports DevExpress.Xpf.Reports.UserDesigner
Imports DevExpress.XtraReports.UI
Imports System.Windows
Imports System.Windows.Media
'...

Public Class ProgressBar ' ...
    Inherits XRControl

End Class
'...

Partial Public Class MainWindow
    Inherits Window

    Public Sub New()
        InitializeComponent()

        Dim icon_Renamed As ImageSource = WpfSvgRenderer.CreateImageSource(New Uri("path/to/progress_bar.svg"))
        ReportDesigner.RegisterControl(Of ProgressBar)(icon_Renamed)
    End Sub

    Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        reportDesigner.OpenDocument(New XtraReport())
    End Sub
End Class

Tip

To unregister a control and remove it from the Toolbox , use the UnregisterControl<T>() method.

See Also

RegisterControl<T>()

UnregisterControl<T>()

ReportDesigner Class

ReportDesigner Members

DevExpress.Xpf.Reports.UserDesigner Namespace