using System.Windows;
using Microsoft.Phone.Controls;
using System.Reflection;
using System;
using System.Windows.Controls;

namespace Controls.Pages
{
    public partial class SelectionPage : PhoneApplicationPage
    {
        public SelectionPage()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            var ss = Assembly.GetExecutingAssembly();
            foreach (Type type in ss.GetTypes())
            { 
                if(type.Namespace.Equals("Controls.Pages") && !type.Name.Equals("SelectionPage"))
                {
                    ListBoxItem lb = new ListBoxItem();
                    lb.Content = type.Name.Replace("Page",String.Empty);
                    lb_Pages.Items.Add(lb);                   
                }
            }
        }

        private void lb_Pages_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {   
            NavigationService.Navigate(new Uri("/Pages/"+((ListBoxItem)lb_Pages.SelectedItem).Content + "Page.xaml",UriKind.Relative));
        }
    }
}