views:

28

answers:

2

Hi All,

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");
  }
}
+1  A: 

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)

Thomas Levesque
Hi Thomas, that's where i went off the reservation. Thanks.
SetiSeeker
A: 

Use an ObservableCollection<string>. List<string> is not built for this type of use, however, ObservableCollections are made exactly for this purpose.

jsmith
Yes, it would be better... but that's not the reason why the grid wasn't displaying anything
Thomas Levesque
+1 you are correct! Good job sir. It would still be wise to switch to an ObservableCollection<string> however. ;)
jsmith