Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / ComboBox в DataGrid'е / 2 сообщений из 2, страница 1 из 1
29.07.2010, 21:13
    #36767297
maratoss
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
ComboBox в DataGrid'е
Подскажите как вывести коллекцию "Color" в ComboBox?
Передаю в DataGrtid коллекцию, в кторой находится коллекция Color для ComboBox'а.
Что нужно прописать, что бы получить коллекцию?
XAML:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
    <Grid x:Name="LayoutRoot" Background="White">
        <data:DataGrid Name="dataGrid1" AutoGenerateColumns="False">
            <data:DataGrid.Columns>
                <data:DataGridTextColumn Header="Bumper" Binding="{Binding Path=Bumper.Value}"></data:DataGridTextColumn>
                <data:DataGridTextColumn Header="Wheel" Binding="{Binding Path=Wheel.Value}"></data:DataGridTextColumn>
                <data:DataGridTemplateColumn>
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox .....???..... />
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
            </data:DataGrid.Columns>
        </data:DataGrid>
    </Grid>

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.
namespace Silver
{
    public partial class MainPage : UserControl
    {
        public class Element
        {
            public int ID { get; set; }
            public string Value { get; set; }

            public Element() { }

            public Element(int ID, string Value)
            {
                this.ID = ID;
                this.Value = Value;
            }
        }

        public class Cars
        {
            public Element Wheel { get; set; }
            public Element Bumper { get; set; }
            public List<Element> Color { get; set; }
        }

        public MainPage()
        {
            InitializeComponent();

            List<Element> color = new List<Element>()
            {
                new Element( 1 , "Red"),
                new Element( 2 , "Orange"),
                new Element( 3 , "Yellow")
            };
            List<Cars> Cars = new List<Cars>()
            {
                new Cars() { Bumper = new Element( 1 , "Tayota"), Wheel = new Element( 1 , "Mishlen"), Color = color},
                new Cars() { Bumper = new Element( 10 , "Bmw"), Wheel = new Element( 11 , "Gradiant"), Color = color},
                new Cars() { Bumper = new Element( 20 , "Mercedes"), Wheel = new Element( 22 , "Mishlen3"), Color = color}
            };

            dataGrid1.ItemsSource = Cars;
        }
    }
}
...
Рейтинг: 0 / 0
29.07.2010, 22:24
    #36767359
maratoss
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
ComboBox в DataGrid'е
Вопрос снимается
<ComboBox ItemsSource="{Binding Path=Color}" DisplayMemberPath="Value" />
...
Рейтинг: 0 / 0
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / ComboBox в DataGrid'е / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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