Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

RichEditControl.ReplaceService<T>(T) Method

Performs a service substitution.

Namespace: DevExpress.Xpf.RichEdit

Assembly: DevExpress.Xpf.RichEdit.v24.2.dll

NuGet Package: DevExpress.Wpf.RichEdit

#Declaration

public T ReplaceService<T>(
    T newService
)
    where T : class

#Parameters

Name Type Description
newService T

A service of the specified type that will be registered.

#Type Parameters

Name
T

#Returns

Type Description
T

Previously registered service of the specified type, or null (Nothing in Visual Basic) if the service does not exist.

#Remarks

Use the ReplaceService<T> method instead of the RichEditControl.GetService -> RichEditControl.RemoveService -> RichEditControl.AddService method sequence.

#Example

View Example

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));
}
See Also