フィールド付きのデータグリッドがありますidsticker
、、。また、フィールドを持つ構造体があります、、volatility
rate of return
container
idsticker
volatility
rateofreturn
struct container
{
public container(string sticker, decimal volatility, decimal rateofreturn)
{
this.sticker = sticker;
this.volatility = volatility;
this.rateofreturn = rateofreturn;
}
string sticker;
decimal volatility;
decimal rateofreturn;
};
構造体を使用してリストを作成し、そこに値を追加します
container cnt = new container(x.Trim(), volatility, ror);
list.Add(cnt);
しかし、この値をリストからdatagridに書き込む方法は?
dataGridControl1.ItemsSource = list;
リストの数とまったく同じ数の行が作成されますが、それらはすべて空です。
xamlでのデータグリッド定義
<xcdg:DataGridControl Height="392" Margin="0,190,534,0" Name="dataGridControl1" VerticalAlignment="Top" AutoCreateColumns="False" ItemsSource="{Binding}" AllowDetailToggle="False">
<xcdg:DataGridControl.Columns>
<xcdg:Column Title="Sticker" ReadOnly="True" FieldName="Sticker"/>
<xcdg:Column Title="Rate of return" ReadOnly="True" FieldName="Rate of return"/>
<xcdg:Column Title="Volatility" FieldName="Volatility" ReadOnly="True"/>
</xcdg:DataGridControl.Columns>
<xcdg:DataGridControl.View>
<xcdg:TableflowView>
<xcdg:TableflowView.Theme>
<xcdg:LunaHomesteadTheme />
</xcdg:TableflowView.Theme>
</xcdg:TableflowView>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>