【发布时间】:2013-12-31 09:19:02
【问题描述】:
我正在尝试将 WCF 服务的结果绑定到 devexpress 查找编辑。
这是我创建的属性
<!-- language: c# -->
public class BindingModel
{
private static List < VW_ClientProcess> _clientProcess= new List< VW_ClientProcess>();
public List< VW_ClientProcess> clientProcess
{
get
{
return _clientProcess;
}
set
{
_clientProcess = value;
OnPropertyChanged("clientProcess");
}
}
}
}
在 WPFApp.xaml.cs 中
BindingModel bind=new BindingModel();
bind.clientProcess = e.Result.GetClientProcessesResult.ToList< VW_ClientProcess>();
这是我的 xaml 代码(WPFApp.xaml)
<dxlc:LayoutGroup>
<dxlc:LayoutGroup.DataContext>
<ViewModel:BindingModel />
</dxlc:LayoutGroup.DataContext>
<dxlc:LayoutItem x:Name="liClientProcess"
Width="auto"
VerticalAlignment="Bottom"
Label="Client Process"
LabelPosition="Top">
<dxg:LookUpEdit x:Name="lueClientProcess"
AutoPopulateColumns="True"
DisplayMember="ClientFullName"
ItemsSource="{Binding clientProcess}"
ValueMember="ProcessID" />
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
问题是当我在 xaml 中设置 ItemSource 时,只显示列名,但数据字段为空。
但是如果我像这样通过 c# 代码设置 ItemSource
BindingModel bind = new BindingModel();
lueClientProcess.ItemsSource = bind.clientProcess;
lookupedit 编辑正在被填充。我是 WPF 的新手。我不知道我在这里做错了什么。
【问题讨论】:
-
sn-ps 代码放在一起没有意义。这是什么
bind对象? -
抱歉,我现在编辑我的问题。 bind 是对象名。
-
仍然很难看到发生了什么......例如,你是如何设置 DataContext 的?
-
感谢您的回复。我将 BindingModel 类设置为 datacontext。
-
谢谢,我想这说明了问题。
标签: c# wpf xaml wcf-binding