SetiSeeker
SetiSeeker

Reputation: 6684

WPF Textbox FlowDirection + HorizontalContentAlignment issue

I have a Control template targeting the ComboBox (TargetType="{x:Type ComboBox}")

In this template is a TextBox:

            <TextBox x:Name="PART_EditableTextBox"
                 FlowDirection="RightToLeft"
                 HorizontalContentAlignment="Left"
                 IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
                 Margin="{TemplateBinding Padding}"
                 VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                 />

My initial issue was the text in the TextBox was cut off at the front of the sentence and showing the end of the sentence.

That is when I added the flow direction in, it solved my original issue but created a new one.

In the TextBox, short text is now Right aligned and no longer left aligned.

Is there an issue setting both FlowDirection + HorizontalContentAlignment in wpf TextBoxes?

and if so, is there a work around?

Upvotes: 1

Views: 2540

Answers (2)

DogeCoin
DogeCoin

Reputation: 1

Try

<TextBox x:Name="PART_EditableTextBox"
         FlowDirection="RightToLeft"
         TextAlignment="Right"
         ... />

Since, FlowDirection is changed we need to set TestAlignment to 'Right' instead of 'Left'

Upvotes: 0

Fredrik Hedblad
Fredrik Hedblad

Reputation: 84674

Try setting HorizontalAlignment="Left" for the TextBox. This way short text will be left aligned as well

<TextBox x:Name="PART_EditableTextBox"
         FlowDirection="RightToLeft"
         HorizontalAlignment="Left"
         ... />

Upvotes: 1

Related Questions