DevExpress WPF 网格绑定到 List使用MVVM
我想做一些应该很简单的事情,但我认为我只是没有看到答案。
我有一个包含多个字符串的列表。
我想将它绑定到 DevExpress DXGrid。
网格似乎显示了正确的行数,但没有显示我的文本。
我正在使用 MVVm 模式,并将 ViewModel 和 View 分开。
感谢您的帮助。
这是 XAML 代码:
<dxg:GridControl Grid.Row="0" DataSource="{Binding Path=ErrorLog}" >
<dxg:GridControl.Columns>
<dxg:GridColumn Header="Error Log" AllowEditing="False" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView NewItemRowPosition="None" />
</dxg:GridControl.View>
</dxg:GridControl>
这是视图模型代码:
private List<string> _errorLog;
public List<string> ErrorLog
{
get { return _errorLog; }
set
{
_errorLog = value;
OnPropertyChanged("ErrorLog");
}
}
I am trying to do something that should be simple, but think I am just not seeing the answer.
I have a List with several strings.
I would like to bind it to a DevExpress DXGrid.
It appears that the grid is showing the correct number of row, but not displaying my text.
I am using the MVVm patern and have seperated my ViewModel and View.
Thanks for the help.
Here is the XAML code:
<dxg:GridControl Grid.Row="0" DataSource="{Binding Path=ErrorLog}" >
<dxg:GridControl.Columns>
<dxg:GridColumn Header="Error Log" AllowEditing="False" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView NewItemRowPosition="None" />
</dxg:GridControl.View>
</dxg:GridControl>
Here is the View Model Code:
private List<string> _errorLog;
public List<string> ErrorLog
{
get { return _errorLog; }
set
{
_errorLog = value;
OnPropertyChanged("ErrorLog");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
GridColumn.DisplayMemberBinding 现在被标记为已过时。建议改用 Binding 属性。
ColumnBase.DisplayMemberBinding 属性
GridColumn.DisplayMemberBinding is now marked as obsolete. It is suggested that the Binding property should be used instead.
ColumnBase.DisplayMemberBinding Property
那不起作用..用这个代替
that doesn't work.. use this instead
您没有指定列应显示的内容,因此它不显示任何内容...
(请注意,没有绑定的路径:列绑定到字符串本身,而不是字符串的成员)
You didn't specify what the column should display, so it's not displaying anything...
(note that there is not path for the binding: the column is bound to the string itself, not a member of the string)