wpf-devexpress-dot-xpf-dot-richedit-dot-richeditcontrol-dot-replaceservice-1-x28-0-x29.md
Performs a service substitution.
Namespace : DevExpress.Xpf.RichEdit
Assembly : DevExpress.Xpf.RichEdit.v25.2.dll
NuGet Package : DevExpress.Wpf.RichEdit
public T ReplaceService<T>(
T newService
)
where T : class
Public Function ReplaceService(Of T As Class)(
newService As T
) As T
| Name | Type | Description |
|---|---|---|
| newService | T |
A service of the specified type that will be registered.
|
| Name |
|---|
| T |
| Type | Description |
|---|---|
| T |
Previously registered service of the specified type, or null ( Nothing in Visual Basic) if the service does not exist.
|
Use the ReplaceService<T> method instead of the RichEditControl.GetService -> RichEditControl.RemoveService -> RichEditControl.AddService method sequence.
void richEditControl1_Loaded(object sender, RoutedEventArgs e) {
ReplaceRichEditCommandFactoryService(richEditControl1);
}
void ReplaceRichEditCommandFactoryService(RichEditControl control)
{
IRichEditCommandFactoryService service = control.GetService<IRichEditCommandFactoryService>();
control.ReplaceService<IRichEditCommandFactoryService>(new CustomRichEditCommandFactoryService(control, service));
}
Private Sub richEditControl1_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
ReplaceRichEditCommandFactoryService(richEditControl1)
End Sub
Private Sub ReplaceRichEditCommandFactoryService(ByVal control As RichEditControl)
Dim service As IRichEditCommandFactoryService = control.GetService(Of IRichEditCommandFactoryService)()
control.ReplaceService(Of IRichEditCommandFactoryService)(New CustomRichEditCommandFactoryService(control, service))
End Sub
See Also