首页 新闻 会员 周边 捐助

使用Csla架构如何实现ListBox 的数据源绑定

0
悬赏园豆:100 [已解决问题] 解决于 2010-08-10 13:56



代码
using System;
using Csla;
using Csla.Serialization;
using ShouWang.Framework;
using System.Linq;
using ShouWang.Framework.BusinessClass;
using System.ComponentModel;
#if !SILVERLIGHT
using ShouWang.Data;
using System.Data;
#endif

namespace ShouWang.ZSOA
{
[Serializable]
public class ReplyConfig :BaseBusiness<ReplyConfig>
{
#region Business Methods
public static PropertyInfo<string> UserIPProperty = RegisterProperty<string>(c => c.UserIP);
public string UserIP
{
get { return GetProperty(UserIPProperty); }
set { SetProperty(UserIPProperty, value); }
}
public static PropertyInfo<SmartDate> AnswerTimeProperty = RegisterProperty<SmartDate>(c => c.AnswerTime, "Name", new SmartDate());
public string AnswerTime
{
get { return GetPropertyConvert<SmartDate, string>(AnswerTimeProperty); }
set { SetPropertyConvert<SmartDate, string>(AnswerTimeProperty, value); }
}
public static PropertyInfo<SmartDate> AdddataProperty = RegisterProperty<SmartDate>(c => c.Adddata, "Name", new SmartDate());
public string Adddata
{
get { return GetPropertyConvert<SmartDate, string>(AdddataProperty); }
set { SetPropertyConvert<SmartDate, string>(AdddataProperty, value); }
}
public static PropertyInfo<string> ContentProperty = RegisterProperty<string>(c => c.Content);
public string Content
{
get { return GetProperty(ContentProperty); }
set { SetProperty(ContentProperty, value); }
}
public static PropertyInfo<string> UserNameProperty = RegisterProperty<string>(c => c.UserName);
public string UserName
{
get { return GetProperty(UserNameProperty); }
set { SetProperty(UserNameProperty, value); }
}
public static PropertyInfo<string> UserIdProperty = RegisterProperty<string>(c => c.UserId);
public string UserId
{
get { return GetProperty(UserIdProperty); }
set { SetProperty(UserIdProperty, value); }
}
public static PropertyInfo<int> ParentIdProperty = RegisterProperty<int>(c => c.ParentId);
public int ParentId
{
get { return GetProperty(ParentIdProperty); }
set { SetProperty(ParentIdProperty, value); }
}
public static PropertyInfo<int> ReplyCountProperty = RegisterProperty<int>(c => c.ReplyCount);
public int ReplyCount
{
get { return GetProperty(ReplyCountProperty); }
set { SetProperty(ReplyCountProperty, value); }
}
public static PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
public int Id
{
get { return GetProperty(IdProperty); }
set { SetProperty(IdProperty, value); }
}
#endregion

//public static void DoSearch(int intId, EventHandler<DataPortalResult<ReplyConfig>> handler)
//{
// DataPortal.BeginFetch<ReplyConfig>(intId, handler);
//}
#if SILVERLIGHT
public ReplyConfig()
{
ModuleId
= "ZSOA_060";
ModuleName
= "批复";
}
#else
private ReplyConfig()
{
ModuleId
= "ZSOA_060";
ModuleName
= "批复";
}
#endif

#if !SILVERLIGHT

#endif
}
}

我需要返回一个集合 集合的代码如下

代码
using System;
using Csla;
using Csla.Serialization;
using ShouWang.Framework;
using System.Linq;
using ShouWang.Framework.BusinessClass;
#if !SILVERLIGHT
using ShouWang.Data;
using System.Data;
#endif

namespace ShouWang.ZSOA
{
[Serializable]
public class ReplyConfigList:BaseReadOnlyList<ReplyConfigList,ReplyConfig>
{
public static ReplyConfigList Query(int intId)
{
return DataPortal.Fetch<ReplyConfigList>(new SingleCriteria<ReplyConfigList, int>(intId));
}

#if !SILVERLIGHT


private void DataPortal_Fetch(int intId)
{
RaiseListChangedEvents
= false;
IsReadOnly
= false;
using (var ctx = ObjectContextManager.GetObjectContext<ZSOAEntities>())
{
var data
= from A in ctx.ObjectContext.ReplyDetail
where A.ParentId == intId
select A;
int i = data.Count();
data.ForEach(t
=>
{
//Add();
//就是这个地方我该怎么写 Add 里面 我要怎样才能添加
});

}
IsReadOnly
= true;
RaiseListChangedEvents
= true;
}
#endif
}
}

 

问题补充: 如何在CSLA 框架下使用Silverlight中实现listBox的数据绑定 有其他的代码也可以 我想借鉴下
缘来丨如此的主页 缘来丨如此 | 初学一级 | 园豆:100
提问于:2010-07-26 16:54
< >
分享
最佳答案
0

ObservableCollection<ReplyConfig> replyConfigList = new ObservableCollection<ReplyConfig>();

然后把   replyConfigList 赋给你的视图类 View 的 DataContext 成员,在 View 的 xaml 中写绑定表达式:

ItemsSource="{Binding Path=DataContext}"

然后你再定义你的列:

<GridViewColumn Header="时间"  DisplayMemberBinding="{Binding Path=AnswerTime
}"/>

收获园豆:100
Launcher | 高人七级 |园豆:45050 | 2010-07-27 09:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册