WPF SyntaxEditor -- Space key does not work when inside ControlTemplate

SyntaxEditor for WPF Forum

Posted 10 years ago by Jon Heaton
Version: 14.1.0602
Avatar

I just downloaded the trial of the WPF controls and am seeing an issue.

My goal is to have the SyntaxEditor embedded within a 3rd party grid control (XamDataGrid).  But I have reproduced the issue by using a ControlTemplate for a TextBox.  The space key is not working.  You can see that the settings are all identical for the two SyntaxEditor's.  The only difference is the ControlTemplate.

<Window x:Class="XamDataGridWithIntelliPrompt.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igDP="http://infragistics.com/DataPresenter"
xmlns:syntaxeditor="http://schemas.actiprosoftware.com/winfx/xaml/syntaxeditor"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="TextBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<syntaxeditor:SyntaxEditor IsMultiLine="False" >
<syntaxeditor:EditorDocument>
<syntaxeditor:EditorDocument.Language>
<syntaxeditor:CSharpSyntaxLanguage />
</syntaxeditor:EditorDocument.Language>
</syntaxeditor:EditorDocument>
</syntaxeditor:SyntaxEditor>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<StackPanel>
<syntaxeditor:SyntaxEditor IsMultiLine="False" >
<syntaxeditor:EditorDocument>
<syntaxeditor:EditorDocument.Language>
<syntaxeditor:CSharpSyntaxLanguage />
</syntaxeditor:EditorDocument.Language>
</syntaxeditor:EditorDocument>
</syntaxeditor:SyntaxEditor>
<TextBox />
</StackPanel>
</Window>

Comments (3)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jon,

My guess is that TextBox has a default internal handler for the space key and thus blocks SyntaxEditor from getting it.  I would not recommend that you put a SyntaxEditor or other interactive control in a TextBox ControlTemplate though.  That seems like a scenario that would just cause problems.

You should probably make a custom template for your data grid cell instead, one that has a SyntaxEditor in it.


Actipro Software Support

Posted 10 years ago by Jon Heaton
Avatar

That's what I was trying to do and simplified it for my post.  Here is my original code:

<Window x:Class="XamDataGridWithIntelliPrompt.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igDP="http://infragistics.com/DataPresenter"
xmlns:syntaxeditor="http://schemas.actiprosoftware.com/winfx/xaml/syntaxeditor"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="syntaxEditorInCellStyle" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<syntaxeditor:SyntaxEditor IsMultiLine="False" >
<syntaxeditor:EditorDocument>
<syntaxeditor:EditorDocument.Language>
<syntaxeditor:CSharpSyntaxLanguage />
</syntaxeditor:EditorDocument.Language>
</syntaxeditor:EditorDocument>
</syntaxeditor:SyntaxEditor>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<StackPanel>
<syntaxeditor:SyntaxEditor IsMultiLine="False" >
<syntaxeditor:EditorDocument>
<syntaxeditor:EditorDocument.Language>
<syntaxeditor:CSharpSyntaxLanguage />
</syntaxeditor:EditorDocument.Language>
</syntaxeditor:EditorDocument>
</syntaxeditor:SyntaxEditor>
<igDP:XamDataGrid DataSource="{Binding Items, Mode=TwoWay}">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:Field Name="ID"/>
<igDP:Field Name="Value">
<igDP:Field.Settings>
<igDP:FieldSettings CellValuePresenterStyle="{StaticResource syntaxEditorInCellStyle}" />
</igDP:Field.Settings>
</igDP:Field>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
</StackPanel>
</Window>

 

Is this what you mean?  This code also does not allow the space key.

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jon,

That DataGrid control is made by another company so you would be best served by asking them how to properly do a custom cell template.  Since SyntaxEditor is just a regular WPF control, it can be plugged into any template that supports custom controls.  But you would need to work with the other company to figure out how to properly do custom cell templates.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.