如何在Silverlight4 Toolkit中数据绑定到AutoCompleteBox? [英] How do you databind to the AutoCompleteBox in the Silverlight4 Toolkit?

查看:96
本文介绍了如何在Silverlight4 Toolkit中数据绑定到AutoCompleteBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该相对简单,但我没有运气好运。  我是设计师,Blend的新手,创建Silverlight SketchFlow应用程序。


我正在尝试将AutoCompleteBox绑定到名为  PaymentType $ b $的数据源b ,它包含一个名为 PayTypeCollection 的集合和一个简单属性
PayType (字符串)。  


如果我只是绑定 对于控件, PayTypeCollection ,列表框打开,但包含"Expression.Blend.SampleData.PaymentType.PayTypeCollectionItem""重复多次。


这是XAML:



< sdk:AutoCompleteBox 


Height =" 24"保证金=" 232,0,412,144" 


VerticalAlignment =" Bottom" 


FilterMode ="包含" 


DataContext =" {Binding Source = {StaticResource PaymentType}}" 


ItemsSource =" {Binding PayTypeCollection}">


< / sdk:AutoCompleteBox>

然后我尝试将 ValueMemberBinding 属性设置为
PayType
列,我可以在文本框中输入,但列表不会打开。

解决方案

您好,


这是一个可能的解决方案,假设您的项目中有以下类(SL4):


 
Public Class PaymentType

Sub New ()

使用 .PaymentTypeCollection
.Add(" Cash"
.Add(" Visa"
.Add(" MasterCard"
结束 使用

End Sub

Public Property PaymentTypeCollection As New 收藏

结束 Class


This should be relatively easy but I'm not having any luck getting it to work.  I'm a designer, new to Blend, creating a Silverlight SketchFlow Application.

I'm trying to bind the AutoCompleteBox to a Data Source named PaymentType and it contains a collection called PayTypeCollection and one simple property PayType (string).  

If I simply bind the  PayTypeCollection to the control, the list box opens, but contains "Expression.Blend.SampleData.PaymentType.PayTypeCollectionItem" repeated multiple times.

Here's the XAML:

<sdk:AutoCompleteBox 

Height="24" Margin="232,0,412,144" 

VerticalAlignment="Bottom" 

FilterMode="Contains" 

DataContext="{Binding Source={StaticResource PaymentType}}" 

ItemsSource="{Binding PayTypeCollection}">

</sdk:AutoCompleteBox>

I then tried to set the ValueMemberBinding property to the PayType column and I can type in the text box but the list doesn't open.

解决方案

Hello,

here is one possible solution, given you have the following class in your project (SL4):

Public Class PaymentType

  Sub New()

    With Me.PaymentTypeCollection
      .Add("Cash")
      .Add("Visa")
      .Add("MasterCard")
    End With

  End Sub

  Public Property PaymentTypeCollection As New Collection

End Class


这篇关于如何在Silverlight4 Toolkit中数据绑定到AutoCompleteBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆