powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / как отобразить массив в Datagrid WPFToolkit
2 сообщений из 2, страница 1 из 1
как отобразить массив в Datagrid WPFToolkit
    #36794660
testing22
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Не получается отобразить массив структур в Datagrid WPFToolkit. Нужное количество строк-полей в окне рисует, но содержимое массива не выводится. То есть не знаю, как правильно заполнить грид данными из массива структур. Прошу помощи.

Код App.xaml.cs:

Код: plaintext
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:

Код: plaintext
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:

Код: plaintext
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>
...
Рейтинг: 0 / 0
как отобразить массив в Datagrid WPFToolkit
    #36796829
sergiy_s
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
переопредели у продукта toString как тебе надо (через запятую например)
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / как отобразить массив в Datagrid WPFToolkit
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]