Вопрос

I am searching how to align left the text in a AutoCompleteBox

So I details,

the result is too long for the textbox associated to autocomplete box, so, there is a missing part.

if the result is : "result of my autocomplete box", when I click and choose it, it's display on the textbox.

But the part display is : "f my autocomplete box", and I want "result of my autocomplete".

Here is my xaml :

<myControl:AutoCompleteBox x:Name="acp" Grid.Row="0" Grid.Column="1" 
           HorizontalAlignment="Left" VerticalAlignment="Top"  
           IsTabStop="False" 
           MinimumPrefixLength="3" 
           ItemTemplate="{StaticResource ItemTemplate}" 
           ValueMemberBinding="{Binding FullName}"
           ItemsSource="{Binding Data, ElementName=MySource}" 
           Text="{Binding FullName, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" 
           Width="150" 
           IsTextCompletionEnabled="False" 
           FilterMode="None" IsDropDownOpen="True"/>

I hope i'm clear. Thank you.

Это было полезно?

Решение

you should try This

<my:AutoCompleteBox Name="acbNames" ValueMemberBinding="{Binding FullName}">
    <my:AutoCompleteBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FullName}" TextAlignment="Left"/>
        </DataTemplate>
    </my:AutoCompleteBox.ItemTemplate>
    </my:AutoCompleteBox>

Другие советы

Please use setter property of AutoCompleteBox to set text alignment like follow:

<toolkit:AutoCompleteBox.TextBoxStyle>
    <Style TargetType="TextBox">
    <Setter Property="TextAlignment" Value="Center"></Setter>
    </Style>
</toolkit:AutoCompleteBox.TextBoxStyle> 

Thanks...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top