我想GetPreviewAsync
在我的 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?
}
...
}
根据文档,它需要一个UIElement
用于预览的对象。
什么样的UIElement
将用于预览代码?我想要与 Visual Studio 提供的现有代码片段生成相同类型的 UI。(见下文)
我也很好奇如何获得Preview Changes
按钮,就像默认灯泡操作中存在的那样。