Click here to Skip to main content
15,847,427 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: GridSplitter Conundrum Pin
SledgeHammer012-Feb-12 15:37
SledgeHammer012-Feb-12 15:37 
GeneralRe: GridSplitter Conundrum Pin
Gil Yoder2-Feb-12 16:43
Gil Yoder2-Feb-12 16:43 
SuggestionRe: GridSplitter Conundrum Pin
Gil Yoder2-Feb-12 19:59
Gil Yoder2-Feb-12 19:59 
GeneralRe: GridSplitter Conundrum Pin
SledgeHammer013-Feb-12 8:17
SledgeHammer013-Feb-12 8:17 
Questionadding/removing ListView columns at runtime (revisited) Pin
Vincent Beek1-Feb-12 1:20
Vincent Beek1-Feb-12 1:20 
AnswerRe: adding/removing ListView columns at runtime (revisited) Pin
Abhinav S1-Feb-12 1:36
Abhinav S1-Feb-12 1:36 
GeneralRe: adding/removing ListView columns at runtime (revisited) Pin
Mycroft Holmes1-Feb-12 12:53
professionalMycroft Holmes1-Feb-12 12:53 
QuestionBinding list of items to IntemsControl in WPF Pin
rams231-Jan-12 0:14
rams231-Jan-12 0:14 
I am facing problems with binding itemscontrol to a list of values. Below is my code in details:

Model code:

public class Employee
{
public string Name { get; set; }
public string Salary { get; set; }
}

public class Department
{
public string DepartmentName { get; set; }
public List<Employee> EmployeeDetails { get; set; }
}


View Model Code:

public ObservableCollection<Department> Departments { get; set; }

Departments = new ObservableCollection<Department>();

Departments.Add(new Department {DepartmentName = "TECH", EmployeeDetails = new List<Employee> {new Employee {Name = "XYZ", Salary = "10000.00" }}});


XAML:

<ItemsControl ItemsSource="{Binding Departments}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander Header="{Binding Path=DepartmentName}" Margin="12,12,12,0" VerticalAlignment="Top">
<Border BorderBrush="Black" BorderThickness="1" x:Name="border1">
<Grid Height="50">
<Grid.RowDefinitions>
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding EmployeeDetails.Name}" TextWrapping="Wrap" FontSize="10"/>
<TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding EmployeeDetails.Salary}" TextWrapping="Wrap" FontSize="10"/>
</Grid>
</Border>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>



The data is not displaying with the code.

If the Department class is as below
public class Department
{
public string DepartmentName { get; set; }
public Employee EmployeeDetails { get; set; }
}

Then it works fine. But I need Department class should be as
public class Department
{
public string DepartmentName { get; set; }
public List<Employee> EmployeeDetails { get; set; }
}

And with this the data is not displaying. Please help me out.

Thanks in Advance,
AnswerRe: Binding list of items to IntemsControl in WPF Pin
Wayne Gaylard31-Jan-12 1:10
professionalWayne Gaylard31-Jan-12 1:10 
GeneralRe: Binding list of items to IntemsControl in WPF Pin
rams231-Jan-12 1:36
rams231-Jan-12 1:36 
GeneralRe: Binding list of items to IntemsControl in WPF Pin
Wayne Gaylard31-Jan-12 1:39
professionalWayne Gaylard31-Jan-12 1:39 
GeneralRe: Binding list of items to IntemsControl in WPF Pin
Abhinav S1-Feb-12 17:26
Abhinav S1-Feb-12 17:26 
GeneralRe: Binding list of items to IntemsControl in WPF Pin
Wayne Gaylard1-Feb-12 20:06
professionalWayne Gaylard1-Feb-12 20:06 
QuestionFocusing on elements in MVVM Pin
mi_n30-Jan-12 23:42
mi_n30-Jan-12 23:42 
AnswerRe: Focusing on elements in MVVM PinPopular
Pete O'Hanlon31-Jan-12 0:03
subeditorPete O'Hanlon31-Jan-12 0:03 
GeneralRe: Focusing on elements in MVVM Pin
Pete O'Hanlon31-Jan-12 4:34
subeditorPete O'Hanlon31-Jan-12 4:34 
GeneralRe: Focusing on elements in MVVM Pin
Wayne Gaylard31-Jan-12 4:39
professionalWayne Gaylard31-Jan-12 4:39 
GeneralRe: Focusing on elements in MVVM Pin
Pete O'Hanlon31-Jan-12 4:47
subeditorPete O'Hanlon31-Jan-12 4:47 
GeneralRe: Focusing on elements in MVVM Pin
Wayne Gaylard31-Jan-12 4:56
professionalWayne Gaylard31-Jan-12 4:56 
GeneralRe: Focusing on elements in MVVM Pin
SledgeHammer0131-Jan-12 6:11
SledgeHammer0131-Jan-12 6:11 
GeneralRe: Focusing on elements in MVVM Pin
SledgeHammer0131-Jan-12 7:18
SledgeHammer0131-Jan-12 7:18 
GeneralRe: Focusing on elements in MVVM Pin
SledgeHammer0131-Jan-12 7:56
SledgeHammer0131-Jan-12 7:56 
GeneralRe: Focusing on elements in MVVM Pin
SledgeHammer0131-Jan-12 8:50
SledgeHammer0131-Jan-12 8:50 
GeneralRe: Focusing on elements in MVVM Pin
mi_n31-Jan-12 7:58
mi_n31-Jan-12 7:58 
GeneralRe: Focusing on elements in MVVM Pin
SledgeHammer0131-Jan-12 8:21
SledgeHammer0131-Jan-12 8:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.