Events
This topic covers the specific events exposed by the RadInlineAIAssistant control.
PromptRequest
The PromptRequest event is raised when the end user submits the prompt input or selects a command from the Commands dropdown. The event arguments are of type InlineAIAssistantPromptRequestEventArgs and expose the following members:
Prompt—Gets the prompt text that was requested by the user (the input text, or the selected command'sText).SelectedText—Gets the currently selected text in the target element, as reported by the currentInteractionProvider.FullText—Gets the full text of the target element, as reported by the currentInteractionProvider.SetResponse(string)—Sets a single, immediate response text.SetResponse(IAsyncEnumerable<string>)—Sets a stream of response chunks that are appended as they arrive.
Read more about setting an immediate or a streamed response in the Handling Responses article.
Using the PromptRequest event to set a response
private void OnPromptRequest(object sender, InlineAIAssistantPromptRequestEventArgs e)
{
// Pass e.Prompt (and, optionally, e.SelectedText / e.FullText) to your AI model.
e.SetResponse("This is a sample AI-generated response.");
}
Opening
The Opening event occurs before a particular instance of RadInlineAIAssistant opens. It is raised only when the assistant is opened through an attached-element trigger—a touch tap-and-hold-then-release gesture on the target element, or an event named in the OpeningEventName property—and is not raised when the IsOpen property is set directly. Setting Handled to true in the handler prevents the assistant from opening.
Canceling the Opening event
private void OnAssistantOpening(object sender, RadRoutedEventArgs e)
{
e.Handled = true;
}
Opened
The Opened event occurs when a particular instance of RadInlineAIAssistant opens, regardless of whether it was opened through the attached-element trigger or by setting IsOpen directly.
Using the Opened event
private void OnAssistantOpened(object sender, RadRoutedEventArgs e)
{
}
Closed
The Closed event occurs when a particular instance of RadInlineAIAssistant closes, regardless of whether it was closed through user interaction (for example, pressing Escape or clicking outside of it) or by setting IsOpen directly.
Using the Closed event
private void OnAssistantClosed(object sender, RadRoutedEventArgs e)
{
}