views:

15

answers:

1

I have the following code in my DataGridTemplateColumn:

<Controls:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
    <StackPanel Orientation="Horizontal">
        <TextBox Text="{Binding AlternateTeacherName, Mode=TwoWay}" Style="{StaticResource InputTextBox}"/>
    </StackPanel>
</DataTemplate>

Style is:

<Style x:Key="InputTextBox" TargetType="TextBox" >
<Setter Property="Margin" Value="1" />
<Setter Property="MinWidth" Value="30" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextAlignment" Value="Left" />
<Setter Property="HorizontalAlignment" Value="Stretch" />

Problem I'm getting is that the textbox fills the column width correctly (including when you resize it) but if I type into the textbox the cursor is not visible when it reaches the end of the line. I'd like the text to scroll off the left so that the current text is still visible.

thanks

A: 

Take out the StackPanel. It aligns its elements from left to right and does not stretch to fill the remaining space. You can probably also get rid of HorizontalAlignment and MinWidth in your Style. If you must set a MinWidth, it should be on the column.

Josh Einstein
I was using the stackpanel to arrange the textbox next to a csla PropertyStatus (which I took out of my example). I've switched to a Grid which has done the trick. Many thanks, I couldn't see what was going on and missed what the stackpanel was doing.
Stephen Price