wpf-devexpress-dot-xpf-dot-reports-dot-userdesigner-dot-reportdesigner-dot-registercontrol-1-x28-system-dot-windows-dot-media-dot-imagesource-x29.md
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
public static void RegisterControl<T>(
ImageSource icon
)
where T : XRControl, new()
Public Shared Sub RegisterControl(Of T As {XRControl, New})(
icon As ImageSource
)
| Name | Type | Description |
|---|---|---|
| icon | ImageSource |
An image source of a control’s icon.
|
| Name | Description |
|---|---|
| T |
The control’s type.
|
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.
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());
}
}
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