Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! I have viewModel that contain the property
C#
public ObservableCollection<ObladnanModel> Collection { get; set; }

That property bind to datagrid:
C#
<DataGrid HorizontalAlignment="Left" Height="133" Margin="34,52,0,0" VerticalAlignment="Top"
                  ItemsSource="{Binding Collection, Mode=TwoWay }" Width="462"                SelectionChanged="DataGrid_SelectionChanged"
                  AutoGenerateColumns="False"  SelectionMode="Single" RenderTransformOrigin="0.413,0.626" Grid.ColumnSpan="2"  >
            <DataGrid.Columns>
                <DataGridTextColumn  Binding="{Binding Id,Mode=TwoWay }" Header="Id"/>
                <DataGridTextColumn  Binding="{Binding Name,Mode=TwoWay}" Header="Name"/>
                <DataGridTextColumn Binding="{Binding Elektromotors,Mode=TwoWay}" Header="Electromotors">
                </DataGridTextColumn>
            </DataGrid.Columns> 
        </DataGrid>
    </Grid>

Model of property Collection is:
C#
public class ObladnanModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public ObservableCollection<ElectromotoruModel> Elektromotors { get; set; }

        public ObladnanModel(int id, string name, ObservableCollection<ElectromotoruModel> electromotors)
        {
            this.Id = id;
            this.Name = name;
            this.Elektromotors = electromotors;
        }
    }

and
C#
public class ElectromotoruModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Marka { get; set; }
    }

But column Electromotors is empty. Can i do something like this
------+-------+--------------+
id    |Name   |Electromotors |
------+-------+--------------+
1     |name1  |Electromotor1 |
      |       +--------------+
      |       |Electromotor2 |
------+-------+--------------+
2     |name2  |Electromotor2 |
      |       +--------------+
      |       |Electromotor5 |
      |       +--------------+
      |       |Electromotor1 |
------+-------+--------------+
Posted
Comments
Maciej Los 19-Aug-15 16:32pm    
Do you want to display electromotor names in one(several) row(s)? Or do you want to display comma separated names?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900