Lightswitch - 使用wCF和Silverlight自定义控件在Lightswitch中显示数据
帮助,帮助,帮助。我已经阅读了很多文章(非常好的文章)。我已经在这3天了,只是无法弄清楚我的问题是什么。
问题:
我创建了一个基于WCF和SilverLight自定义控件的屏幕。当我在编辑细节屏幕上使用它时,WCF正在查找(它会带回数据)。在同一个屏幕上,我添加了自定义控件,但数据没有绑定。 WCF具有GetGamerProfile(Guid?,userId)方法,该方法用作屏幕成员的数据源(屏幕的左侧)。我创建了一个用于参数(userid)的查询和屏幕参数。这一切都运行正常,但自定义控件绑定不起作用。我还没有尝试绑定图像,因为我无法使简单的文本框绑定工作。基本上,自定义控件绑定不起作用。
XAML代码:
Help, Help, Help. I have read lots of articles (very good articles) on this. I have been at this for 3 days now and just can't figure out what my problem is.
The Problem:
I created a Screen based on a WCF and SilverLight Custom Control. The WCF is working find when I use it on the Edit Detail Screen (it brings back the data). On the same screen, I add the custom control, but the data is not binding. The WCF has a GetGamerProfile(Guid?, userId) method which is used as the datasource for the screen member (left side of screen). I created a query and screen parameter to use for the parameter (userid). This is all working fine, but the custom control binding is not working. I did not tried to bind the image yet, because I couldn't get the simple textbox binding to work. Basically, the Custom Control binding is not working.
XAML Code:
sdk:TabItem Header="Profile" Name="tabItemProfile" DataContext="{Binding Screen.GetGamerProfile}"
TextBox Height="23" HorizontalAlignment="Left" Margin="269,7,0,0" Name="tbxCareer" VerticalAlignment="Top" Width="120" Grid.Column="1" Text="{Binding
Screen.Career,Mode=TwoWay}"
注意:文本框是TabItem(tabItemProfile)
WCF代码(工作正常):
Note: textbox is part of the TabItem (tabItemProfile)
WCF Code (which is working):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Data.EntityClient;
using System.ServiceModel.DomainServices.Server;
using System.Web.Configuration;
using limitlessData.Implementation;
namespace GamerProfileWCF
public class GamerProfile
{
[Key]
public Guid GamerProfileGUID { get; set; }
[Key]
public Guid UserProfileGUID { get; set; }
public string Career { get; set; }
public byte[] AvartarImage { get; set; }
}
public class GamerProfileWCF : System.ServiceModel.DomainServices.Server.DomainService
{
private limitlessDataObjectContext context;
public limitlessDataObjectContext Context
{
get
{
if (this.context == null)
{
EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder();
builder.Metadata =
"res://*/limitlessData.csdl|res://*/limitlessData.ssdl|res://*/limitlessData.msl";
builder.Provider = "System.Data.SqlClient";
builder.ProviderConnectionString =
WebConfigurationManager.ConnectionStrings["limitlessData"].ConnectionString;
this.context = new limitlessDataObjectContext(builder.ConnectionString);
}
return this.context;
}
}
[Query(IsDefault = true)]
public IQueryable<gamerprofile> GetGamers()
{
return this.Context.GAMER_PROFILEs
.Select(g =>
new GamerProfile()
{
GamerProfileGUID = (Guid)g.gamer_profile_id,
UserProfileGUID = (Guid)g.user_profile_id,
AvartarImage = (byte[])g.avartar_Image,
Career = g.career
});
}
[Query(IsComposable = false)]
public IQueryable<gamerprofile> GetGamerProfile(Guid? userID)
{
userID = new Guid("7b984d40-48e2-4be1-94ce-5281b4170406");
return (from userP in this.Context.USER_PROFILEs
join gamerP in this.Context.GAMER_PROFILEs on userP.user_profile_id equals gamerP.user_profile_id
where userP.user_profile_id == userID
select new GamerProfile()
{
GamerProfileGUID = (Guid)gamerP.gamer_profile_id,
UserProfileGUID = (Guid)userP.user_profile_id,
AvartarImage = (byte[]) gamerP.avartar_Image,
Career = gamerP.career
});
}
}
}
我收到一封电子邮件,说明richcb更新了我的问题;但是,我没有看到richcb update。
I got an email stating that richcb updated my question; however, I don't see richcb update.