How do I get a xamdatagrid field to accept returns as part of the input, instead of finishing the edit?
I can't see a property on XamTextEditor to do this.
Thanks
<igDP:XamDataGrid Name="xamDataGrid1">
<igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="MyFieldName"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style> </Style.Resources> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="MyFieldName"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style> </Style.Resources> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields> <igDP:Field Name="MyFieldName"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style> </Style.Resources> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields>
<igDP:FieldLayout.Fields>
<igDP:Field Name="MyFieldName"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style> </Style.Resources> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
<igDP:Field Name="MyFieldName">
<igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style> </Style.Resources> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings>
<igDP:Field.Settings>
<igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style> </Style.Resources> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings>
<igDP:FieldSettings>
<igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style> </Style.Resources> </Style> </igDP:FieldSettings.EditorStyle>
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style> </Style.Resources> </Style>
<Style TargetType="{x:Type igEditors:XamTextEditor}">
<Style.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style> </Style.Resources>
<Style.Resources>
<Style TargetType="{x:Type TextBox}"> <Setter Property="AcceptsReturn" Value="True"/> </Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="AcceptsReturn" Value="True"/>
</Style>
</Style.Resources>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
"johnsparrowuk" wrote in message news:19904@forums.infragistics.com... Hi Joe, I can see how to add the style to the resources of the whole grid, making all text fields accept returns. But how do I only add it to some fields? This doesn't work, where newstyle is the one altering AcceptsReturn: <my:Field Name="Name"> <my:Field.Settings> <my:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}"> <my:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Setter Property="TextWrapping" Value="Wrap"/> <Setter Property="Style" Value="newstyle" /> </Style> </my:FieldSettings.EditorStyle> </my:FieldSettings> </my:Field.Settings> </my:Field> http://forums.infragistics.com/forums/p/3729/19904.aspx#19904
Hi Joe,
I can see how to add the style to the resources of the whole grid, making all text fields accept returns. But how do I only add it to some fields? This doesn't work, where newstyle is the one altering AcceptsReturn:
<my:Field Name="Name">
<my:Field.Settings>
<my:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}">
<my:FieldSettings.EditorStyle>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Style" Value="newstyle" />
</my:FieldSettings.EditorStyle>
</my:FieldSettings>
</my:Field.Settings>
</my:Field>
I have a hack if there isn't an elegent solution:
Style the XamTextEditor to call an event when edit mode starts:
<my:Field Name="Name"><my:Field.Settings><my:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}"><my:FieldSettings.EditorStyle><Style TargetType="{x:Type igEditors:XamTextEditor}"><EventSetter Event="EditModeStarted" Handler="EditStarted" /></Style></my:FieldSettings.EditorStyle></my:FieldSettings></my:Field.Settings></my:Field>
Then in the event handler, walk the visual tree to find the TextBox that's hanging off XamTextEditor, and set the AcceptReturns property:
public void EditStarted(object sender, EditModeStartedEventArgs e){ TextBox b = (TextBox)VisualTreeWalker.FindFirst((Visual)e.Source, typeof(TextBox)); b.AcceptsReturn = true;}
I haven't included VisualTreeWalker here, but it's simple enough code.
Any better solution?
Thanks,
John