对不起,但我是 wpf 的新手,我有一个名为 generateMessage 的类,并试图将它与数据网格绑定。
class generatedMessage
{
public CanMessage cmsg { set; get; }
public int cycleTime { set; get; }
public generatedMessage(){}
}
public class CanMessage
{
public byte[] data { set; get; }
public ushort dlc { set; get; }
public ushort flags { set; get; }
public uint id { set; get; }
public ulong res1 { set; get; }
public ulong res2 { set; get; }
}
如您所见,generatedMessage 类有一个 CanMessage 类的对象,我之前使用 CanMessage 类完成了此操作,如下所示
TraceTable.Items.Add /*- at TraceTable is a datagrid -*/
(
new CanMessage()
{
data = msg.data,
dlc = msg.dlc,
id = msg.id,
flags = msg.flags,
res1 = msg.res1,
res2 = msg.res2
}
);
//xml file below
<DataGrid x:Name="TraceTable" Grid.Column="0" DockPanel.Dock="Top" SelectionMode="Extended" AutoGenerateColumns="False" SelectionUnit="FullRow" Margin="0,45,4,0">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=data}" Header="Data" IsReadOnly="true"/>
<DataGridTextColumn Binding="{Binding Path=dlc}" Header="DLC" IsReadOnly="true"/>
<DataGridTextColumn Binding="{Binding Path=id}" Header="ID" IsReadOnly="true"/>
<DataGridTextColumn Binding="{Binding Path=flag}" Header="Flag" IsReadOnly="true"/>
<DataGridTextColumn Binding="{Binding Path=res1}" Header="Res1" IsReadOnly="true"/>
<DataGridTextColumn Binding="{Binding Path=res2}" Header="Res2" IsReadOnly="true"/>
</DataGrid.Columns>
</DataGrid>
所以我的问题是如何使用 generateMessage 类来制作它?我希望数据网格查看所有 canMessage 属性 + 循环时间(具有 7 列的数据网格)