Не получается отобразить массив структур в Datagrid WPFToolkit. Нужное количество строк-полей в окне рисует, но содержимое массива не выводится. То есть не знаю, как правильно заполнить грид данными из массива структур. Прошу помощи.
Код App.xaml.cs:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
namespace WpfApplication1
{
public partial class App : Application
{
private static StoreDB storeDB = new StoreDB();
public static StoreDB StoreDB
{
get { return storeDB; }
}
}
public class Product
{
private structBook[] array;
public structBook[] Array
{
get { return Array; }
set { array = value; }
}
}
public class StoreDB
{
public structBook[] GetNumder()
{
structBook[] Array = new structBook[ 6 ];
Array[ 1 ].iVolume = 10 ;
Array[ 2 ].iVolume = 1 ;
Array[ 3 ].iVolume = 502 ;
Array[ 4 ].iVolume = 1 ;
Array[ 5 ].iVolume = 10 ;
Array[ 1 ].dSize = 1586 . 80 ;
Array[ 2 ].dSize = 1586 . 13 ;
Array[ 3 ].dSize = 1586 . 00 ;
Array[ 4 ].dSize = 1585 . 90 ;
Array[ 5 ].dSize = 1585 . 41 ;
return Array;
}
}
//формат структуры
public struct structBook
{
public int iVolume;
public double dSize;
}
}
Код Window1.xaml.cs:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
namespace WpfApplication1
{
public partial class Window1 : Window
{
private void button1_Click(object sender, RoutedEventArgs e)
{
//по нажатию кнопки на window закрепляю источник данных, но что делать дальше не знаю
dataGrid1.ItemsSource = App.StoreDB.GetNumder();
//dockPanel1.DataContext = App.StoreDB.GetNumder(); ???
}
}
}
Код разметки Window1.xaml:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="523" Width="591" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit">
<DockPanel Height="474" Name="dockPanel1" Width="549" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0">
<Button Height="79" Name="button1" Width="Auto" DockPanel.Dock="Bottom" Click="button1_Click">Button</Button>
<my:DataGrid AutoGenerateColumns="False" Height="304" Name="dataGrid1" Width="436">
//???
<my:DataGrid.Columns>
<my:DataGridTextColumn Binding="{Binding Path=iVolume}" Header="iVolume" />
<my:DataGridTextColumn Binding="{Binding Path=dSize}" Header="dSize" />
</my:DataGrid.Columns>
</my:DataGrid>
</DockPanel>
</Window>