Posted 15 years ago
by Bradley
I had download the evaluation of WPF Studio and had gotten SyntaxEditor to work in my code, including the IntelliPrompt stuff. We purchased the release version and after I set the references to the new stuff everything works except the IntelliPrompt. I can put the code for it in a button and it will show up when clicked, but ctrl+space isn't bringing it up like it was in the evaluation code. The code is taken directly from the sample:
Inside constructor:Everything else:
You'll notice it is exactly what's in the sample browser code, which does work as intended. Any ideas would be appreciated, thanks.
Inside constructor:
CommandManager.RegisterClassCommandBinding(typeof(EditorWindow), new CommandBinding(EditorCommands.IntelliPromptCompleteWord, OnIntelliPromptCompleteWordExecuted));
/// <summary>
/// Occurs when the <see cref="RoutedCommand"/> is executed.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="e">An <see cref="ExecutedRoutedEventArgs"/> that contains the event data.</param>
private static void OnIntelliPromptCompleteWordExecuted(object sender, ExecutedRoutedEventArgs e)
{
EditorWindow control = sender as EditorWindow;
control.ShowCompletionList(true);
}
private void ShowCompletionList(bool allowAutoComplete)
{
//
// IMPORTANT NOTE:
// The items for this completion list are hardcoded in this sample and
// are simply meant to illustrate the rich features of the SyntaxEditor completion list.
// When implementing a real language, you should vary the items based
// on the current context of the caret.
//
// Create a session
CompletionSession session = new CompletionSession();
session.CanCommitWithoutPopup = allowAutoComplete;
session.MatchOptions = CompletionMatchOptions.TargetsDisplayText;
// HTML allows ! and - characters to be typed too... make sure they are inserted
session.AllowedCharacters.Add('!');
session.AllowedCharacters.Add('-');
// Add some items
session.Items.Add(new CompletionItem("!--", new CommonImageSourceProvider(CommonImage.XmlComment),
new HtmlQuickInfoContentProvider("<b><!-- --></b> Comment<br/><span style=\"color: #008000;\">A comment.</span>"),
"<!-- ", " -->"));
session.Items.Add(new CompletionItem("a", new CommonImageSourceProvider(CommonImage.XmlTag),
new HtmlQuickInfoContentProvider("<b>a</b> Element<br/><span style=\"color: #008000;\">A hyperlink to another URL.</span>"),
"<a href=\"", "\""));
session.Items.Add(new CompletionItem("br", new CommonImageSourceProvider(CommonImage.XmlTag),
new HtmlQuickInfoContentProvider("<b>br</b> Element<br/><span style=\"color: #008000;\">Creates a line break.</span>"),
"<br/>", null));
// Open the session
session.Open(TextEditor.ActiveView, new TextRange(TextEditor.ActiveView.Selection.EndOffset));
}