DevEx preSS WPF电网必将列出<串GT;使用MVVM [英] DevExpress WPF grid bound to List<String> using MVVM

查看:206
本文介绍了DevEx preSS WPF电网必将列出<串GT;使用MVVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一些事情,应该是简单的,但认为我只是没有看到答案。​​

我有几个字符串的列表。

我想将其绑定到一个DevEx preSS DXGrid。

似乎网格表示行的正确数目,但不显示我的文本

我使用的MVVM百通,并已分开我的视图模型和视图。

感谢您的帮助。

下面是XAML code:

 < D​​XG:GridControl Grid.Row =0数据源={绑定路径=错误日志}>
          < D​​XG:GridControl.Columns>
            < D​​XG:页眉的GridColumn =错误日志AllowEditing =FALSE/>
          < / DXG:GridControl.Columns>
          < D​​XG:GridControl.View>
            < D​​XG:TableView中NewItemRowPosition =无/>
          < / DXG:GridControl.View>
     < / DXG:GridControl>

下面是视图模型code:

 私人列表<串GT; _errorLog;
公开名单<串GT;错误日志
{
  {返回_errorLog; }
  组
  {
    _errorLog =价值;
    OnPropertyChanged(错误日志);
  }
}


解决方案

您没有指定栏应该显示什么,所以它不会显示任何内容...

 < D​​XG:页眉的GridColumn =错误日志AllowEditing =FALSEDisplayMemberBinding ={结合}/>

(注意,不是为装订路径:该列被绑定到字符串本身,而不是一个字符串的部件)

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");
  }
}

解决方案

You didn't specify what the column should display, so it's not displaying anything...

<dxg:GridColumn Header="Error Log" AllowEditing="False" DisplayMemberBinding="{Binding}" />

(note that there is not path for the binding: the column is bound to the string itself, not a member of the string)

这篇关于DevEx preSS WPF电网必将列出&LT;串GT;使用MVVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆