I want to display a code preview in the GetPreviewAsync
method on my clas ISuggestedAction
.
public class BaseAction : ISuggestedAction
{
...
//
// Summary:
// Gets an object visually representing a preview of the suggested action.
//
// Parameters:
// cancellationToken:
// A cancellation token that allows to cancel preview creation.
//
// Returns:
// A task whose result is an object visually representing a preview of the suggested
// action, or null if no preview can be provided.
//
// Remarks:
// The only currently supported type of preview object is System.Windows.UIElement.
// By default preview panel gets highlighted when focused by setting background
// color to Microsoft.VisualStudio.Language.Intellisense.LightBulbPresenterStyle.PreviewFocusBackgroundBrush.
// When providing a preview object make sure it doesn't set different background
// for the whole preview content, otherwise it's recommended that preview object
// indicates focused state using Microsoft.VisualStudio.Language.Intellisense.LightBulbPresenterStyle.PreviewFocusBackgroundBrush
// color.
public async Task<object> GetPreviewAsync(CancellationToken cancellationToken)
{
// How do I return c# code to preview?
}
...
}
According to the docs, it requires a UIElement
object to be used for the preview.
Where kind of UIElement
would be used for previewing code? I want the same kind of UI as used for the existing code snippet generation provided by Visual Studio. (See below)
I am also curious about how to get the Preview Changes
button just like is present in the default light bulb actions.