我湄包含此方法的WCF服務:如何綁定表的數據組合框
public List<LocationDB> GetLocation()
{
List<LocationDB> locations = null;
using (SqlConnection connection = new SqlConnection(conn))
{
using (SqlCommand command = new SqlCommand())
{
command.Connection = connection;
command.CommandText = string.Format("Select L_ID ,L_Name from Location");
connection.Open();
//code to fill the locations list..
我的問題是,當我想要的結果,從這個方法在我的代碼我這樣做綁定。
void MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
client.GetLocationCompleted += new EventHandler<GetLocationCompletedEventArgs>(client_GetLocationCompleted);
client.GetLocationAsync();
}
}
和:
void client_GetLocationCompleted(object sender, GetLocationCompletedEventArgs e)
{
LocationCombo.ItemsSource = e.Result;
LocationCombo.SelectedValuePath =
LocationCombo.DisplayMemberPath =
}
最後我LocationDB類,它是坐落在ASP網站App_Code文件夾:
[DataContract]
public class LocationDB
{
[DataMember]
public int Lid { get; set; }
[DataMember]
public int SmId { get; set; }
[DataMember]
public string Lname { get; set; }
我怎樣才能綁定SelectedValePath和的DisplayMemberPath在代碼中不在XAML中。 謝謝
OMG,它的工作原理,我沒有想到會這麼容易..謝謝很多 – AboKevo 2012-04-02 22:16:30