Here is my XAML, in windows phone, I am setting the data using MVVM to the page, but i cannot find any data on the listbox.
<ListBox Grid.Row="0" SelectionMode="Single" SelectedItem="{Binding CurrentSelectedEmployee, Mode=TwoWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding FirstName}"></TextBlock>
<TextBlock Width="5"></TextBlock>
<TextBlock Text="{Binding LastName}"></TextBlock>
</StackPanel>
<TextBlock Text="{Binding Description}" TextWrapping="Wrap"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
And my ViewModel,
public MainViewModel()
{
Employees = new ObservableCollection<Model.Employee>();
}
public bool IsLoaded { get; set; }
public void LoadData()
{
Employees = CompanyDataPhone.Service.EmployeeService.GetEmployees();
IsLoaded = true;
}
// public ObservableCollection<Model.Employee> Employees { get; set; }
public ObservableCollection<CompanyDataPhone.Model.Employee> _employees;
public ObservableCollection<CompanyDataPhone.Model.Employee> Employees
{
get {
return _employees;
}
set
{
_employees = value;
OnpropertyChanged();
}
}
Here I am setting the viewmodel to mainPage,
public MainPage()
{
InitializeComponent();
this.DataContext = App.ViewModel;
}
but i cannot find any detail on Page!, what could be the reason?
You have not assigned any values to the ItemsSource Property of your Listbox,
In your XAML,