Автозаполнение - Зло - PullRequest
       4

Автозаполнение - Зло

0 голосов
/ 22 февраля 2012

Вот вопрос:

Почему AutoCompleteBox ненавидит меня ?? Я потратил как минимум 3 дня, пытаясь заставить ACB отображать данные в выпадающем списке. Все, что я получаю, это имя класса в выпадающем списке. Listbox работает отлично.

Спасибо за ваше время и усилия!

Вот картинка того, что он делает: image

Теперь вот XAML для списка

    <ListBox Height="100" HorizontalAlignment="Left" Margin="367,81,0,0" Name="ListBox1" VerticalAlignment="Top" Width="184" ItemsSource="{Binding}" >
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Together}" />
                    <TextBlock Text=" sadssa" />
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

Вот XAML для AutoCompleteBox

<sdk:AutoCompleteBox x:Name="atcTextBox" ItemsSource="{Binding}" ValueMemberPath="CountryNumber" FilterMode="StartsWith"
            IsTextCompletionEnabled="True" Height="30" MinimumPopulateDelay="0" MinimumPrefixLength="0" Margin="29,225,259,225">
            <sdk:AutoCompleteBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=CountryName}" />
                        <TextBlock Text="{Binding Path=Together}" />
                    </StackPanel>
                </DataTemplate>
            </sdk:AutoCompleteBox.ItemTemplate>
        </sdk:AutoCompleteBox>

И Код позади.

Partial Public Class pgMain
    Inherits Page

    Public Sub New()
        InitializeComponent()

        Dim a = GetCountry()
        ListBox1.ItemsSource = a
        atcTextBox.ItemsSource = a
    End Sub

    Private Function GetCountry() As List(Of Country)
        Dim lstCountry As New List(Of Country)()
        lstCountry.Add(New Country() With {.CountryName = "India"})
        lstCountry.Add(New Country() With {.CountryName = "USA"})
        lstCountry.Add(New Country() With {.CountryName = "Australia"})
        lstCountry.Add(New Country() With {.CountryName = "Germany"})
        lstCountry.Add(New Country() With {.CountryName = "England"})
        Return lstCountry
    End Function

End Class

Public Class Country
    Private m_CountryName As String
    Public Property CountryName() As String
        Get
            Return m_CountryName
        End Get
        Set(ByVal value As String)
            m_CountryName = value
        End Set
    End Property

    Private m_CountryNumber As Integer

    Public Property CountryNumber As Integer
        Get
            Return m_CountryNumber
        End Get
        Set(value As Integer)
        End Set
    End Property

    Public ReadOnly Property Together
        Get
            Return m_CountryName & " " & m_CountryNumber.ToString
        End Get
    End Property

    Public Sub New()
        m_CountryNumber = Rnd(Timer) * 100
    End Sub
End Class

1 Ответ

1 голос
/ 23 февраля 2012

нашел ответ.

Тема вызывала ошибку в AutocompleteBox.Я удалил тему, и теперь окно автозаполнения работает.

    <toolkit:Theme ThemeUri="/System.Windows.Controls.Theming.BureauBlue;component/Theme.xaml">
    </toolkit:Theme>

Теперь, чтобы посмотреть, есть ли исправление для этого ..

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...