.NET 4.5 TypeInfo Reflection: Listing 2

Complete MainPage.xaml.cs

using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using System.Reflection;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace VSMTypeInfoDemo
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Assembly myAssembly = this.GetType().GetTypeInfo().Assembly;
            IEnumerable<TypeInfo> myTypes = myAssembly.DefinedTypes;
            MyDefinedTypes.DataContext = myTypes;
        }

        private void MyDefinedTypes_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                TypeInfo selectedTypeInfo = e.AddedItems.First() as TypeInfo;
                TypeInfoDetails.DataContext = selectedTypeInfo;
		 TypeInfoDetails.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
        }
    }
}

About the Author

Eric Vogel is a Senior Software Developer for Red Cedar Solutions Group in Okemos, Michigan. He is the president of the Greater Lansing User Group for .NET. Eric enjoys learning about software architecture and craftsmanship, and is always looking for ways to create more robust and testable applications. Contact him at vogelvision@gmail.com.