首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AutoCompleteBox是邪恶的

AutoCompleteBox是邪恶的
EN

Stack Overflow用户
提问于 2012-02-23 02:25:22
回答 1查看 402关注 0票数 0

下面是问题:

为什么AutoCompleteBox讨厌我??我花了至少3天的时间试图让ACB在下拉列表中显示数据。我得到的只是下拉列表中的类名。THe列表框可以完美地工作。

感谢您的时间和努力!

下面是它的工作原理的图片:

下面是列表框的XAML

代码语言:javascript
复制
    <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>

下面是AutoCompleteBox的XAML

代码语言:javascript
复制
<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>

代码隐藏在后面。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-23 20:48:12

找到答案了。

主题化导致了AutocompleteBox中的错误。我删除了主题,自动完成框现在可以工作了。

代码语言:javascript
复制
    <toolkit:Theme ThemeUri="/System.Windows.Controls.Theming.BureauBlue;component/Theme.xaml">
    </toolkit:Theme>

现在看看有没有解决这个问题的办法..

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9400713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档