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 Templa开发者_StackOverflow社区tedParent}}"
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?
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"
... />
Try
<TextBox x:Name="PART_EditableTextBox"
FlowDirection="RightToLeft"
TextAlignment="Right"
... />
Since, FlowDirection is changed we need to set TestAlignment to 'Right' instead of 'Left'
精彩评论