Align left text when focus and text are selected

So here's my problem. In any TextBox or control that includes a TextBox (for example, for an AutoComplete ComboBox such as a RadComboBox with IsEditable = "True"), it expects behavior that, after text is selected and selected, is right-justified so you can see the end.

The problem I am running into can be demonstrated really simply by something like:

<TextBox Text="Blah1 Blah2 Blah3 Blah4 Blah5 Blah6 Blah7 Blah8 Blah9 Blah10" Width="75"/>

visual link;

enter image description here

So when it is displayed you only see "Blah1 Blah2", but if you select / select all the text, it will automatically jump to correct alignment. This is fine in most cases, but the problem in this case is that the user wants to select / highlight the contained text and leave it to the left if selected / selected and ignore the overflow. (Edit: don't completely ignore the overflow, just don't show it highlighted and stay left)

I've tried using what I know, just not trying to hunt down what the behavior is. Does anyone know a useful trick or some property that I somehow forgot or something like that?

+3


source to share


1 answer


Ok, so it took me a little while to track down the culprit and figure out a fix, but this approach works adorable for the first part of my problem and the second part.

Everything I ended up with for the first part of my problem (which was an editable combobox, always displaying the contents of the selected context area, either right or center) was linked to an event trigger in the checklist to set SelectionStart

\ SelectionLength

to "0" on load. This basically allowed it to populate and then remove that damn text back to left alignment and was less than painful in my *** than expected.

So something like (in pseudo);



<ControlTemplate>
   <TextBox>
      <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                  <ei:ChangePropertyAction TargetName="PART_EditableTextBox"
                                                     PropertyName="SelectionLength"
                                                     Value="0" />
            </i:EventTrigger>
       </i:Interaction.Triggers>
    </TextBox>
</ControlTemplate>

      

and more or less the same type as when selecting text and also when setting SelectionStart

back to "0", love SL, thanks for watching.

+3


source







All Articles