WPF MVVM binding DataGrid to an IEnumerable causes binding errors to Int32

I’m writing a simple WPF interface to retrieve SwiftMessages using a library component. I cannot change the component. I have a DataGrid that should show the messages, one message per row.

My only use of code-behind is to instantiate the DataContext (so yes dear MVVM absolutionists, it’s not 100% MVVM, but please be nice and useful as I’m learning):

public SwiftSearchWindow()
{
    InitializeComponent();
    DataContext = new UI.ViewModels.SwiftSearchViewModel();
}

The relevant XAML is thus:

<DataGrid Name="gridMessages" ItemsSource="{Binding SwiftMessages}">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Message Type"  Binding="{Binding MessageType, Mode=OneWay}" ></DataGridTextColumn>
        <DataGridTextColumn Header="Message Length" Binding="{Binding MessageLength, Mode=OneWay}"></DataGridTextColumn>
        <DataGridTextColumn Header="Counter Party"  Binding="{Binding CounterParty, Mode=OneWay}"></DataGridTextColumn>
        <DataGridTextColumn Header="Direction"  Binding="{Binding Direction, Mode=OneWay}"></DataGridTextColumn>
        <DataGridTextColumn Header="Message Date"  Binding="{Binding MessageDate, Mode=OneWay}"></DataGridTextColumn>
        <DataGridTextColumn Header="Network Interface Message Reference" Binding="{Binding NetworkInterfaceMessageReference, Mode=OneWay}"/>
        <DataGridTextColumn Header="Own Bic" Binding="{Binding OwnBic, Mode=OneWay}"></DataGridTextColumn>
    </DataGrid.Columns>
</DataGrid>

On my instance of SwiftSearchViewModel is a property:

public SwiftMessages SwiftMessages
{
    get
    {
        if (_query == null) return null;
        return _query?.Messages;
    }
}

Relevant parts of SwiftMessages are:

    public class SwiftMessages : IEnumerable, IEnumerator
    {
        private List<SwiftMessage> _items;
    }

…and relevant parts of SwiftMessage are below. I’ve omitted some of the properties, but they’re all strings, except for MessageLength:

    public class SwiftMessage
    {
        public int MessageLength
        {
            get { return _messageLength; }
            set { _messageLength = value; }
        }


        public string MessageType
        {
            get { return _messageType; }
            set { _messageType = value; }
        }
    }

Two messages are retrieved and I get two rows shown in the DataGrid. However, the individual cell values do not bind. I get these errors:

System.Windows.Data Error: 40 : BindingExpression path error: 'MessageType' property not found on 'object' ''Int32' (HashCode=1)'. BindingExpression:Path=MessageType; DataItem='Int32' (HashCode=1); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'MessageLength' property not found on 'object' ''Int32' (HashCode=1)'. BindingExpression:Path=MessageLength; DataItem='Int32' (HashCode=1); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'CounterParty' property not found on 'object' ''Int32' (HashCode=1)'. BindingExpression:Path=CounterParty; DataItem='Int32' (HashCode=1); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'Direction' property not found on 'object' ''Int32' (HashCode=1)'. BindingExpression:Path=Direction; DataItem='Int32' (HashCode=1); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'MessageDate' property not found on 'object' ''Int32' (HashCode=1)'. BindingExpression:Path=MessageDate; DataItem='Int32' (HashCode=1); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'NetworkInterfaceMessageReference' property not found on 'object' ''Int32' (HashCode=1)'. BindingExpression:Path=NetworkInterfaceMessageReference; DataItem='Int32' (HashCode=1); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'OwnBic' property not found on 'object' ''Int32' (HashCode=1)'. BindingExpression:Path=OwnBic; DataItem='Int32' (HashCode=1); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'MessageType' property not found on 'object' ''Int32' (HashCode=2)'. BindingExpression:Path=MessageType; DataItem='Int32' (HashCode=2); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'MessageLength' property not found on 'object' ''Int32' (HashCode=2)'. BindingExpression:Path=MessageLength; DataItem='Int32' (HashCode=2); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'CounterParty' property not found on 'object' ''Int32' (HashCode=2)'. BindingExpression:Path=CounterParty; DataItem='Int32' (HashCode=2); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'Direction' property not found on 'object' ''Int32' (HashCode=2)'. BindingExpression:Path=Direction; DataItem='Int32' (HashCode=2); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'MessageDate' property not found on 'object' ''Int32' (HashCode=2)'. BindingExpression:Path=MessageDate; DataItem='Int32' (HashCode=2); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'NetworkInterfaceMessageReference' property not found on 'object' ''Int32' (HashCode=2)'. BindingExpression:Path=NetworkInterfaceMessageReference; DataItem='Int32' (HashCode=2); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'OwnBic' property not found on 'object' ''Int32' (HashCode=2)'. BindingExpression:Path=OwnBic; DataItem='Int32' (HashCode=2); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

My questions are:

  1. What Int32 is it trying to bind to?
  2. I’m aware that I’m simply using an IEnumerable from a C# library and trying to bind to it. I consider the data generated by the library to be my Model. I’ve seen other examples where the model constructs ObservableCollections etc (not possible in this case) to feed the UI, but surely that breaks the concept that the Model should work independantly of the UI.
  3. How do I fix this so that the properties show?
  4. Lastly, I have a few other properties of SwiftMessage that are string[]. I’d like to concatenate the array into a single CSV string and show that in a cell. How do I slot this calculation inbetween the XAML and the model data?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật