Exemplo n.º 1
0
        /// <summary>
        /// Occurs when the selection of show case demos
        /// </summary>
        private void ShowcaseList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListView listView = sender as ListView;

            if (listView != null && listView.SelectedItem is DemoInfo && sampleBrowserViewModel != null)
            {
                try
                {
                    DemoInfo demo = listView.SelectedItem as DemoInfo;
                    if (demo.ShowBusyIndicator)
                    {
                        sampleBrowserViewModel.IsShowCaseDemoBusy = true;
                    }
                    var window = Activator.CreateInstance(demo.DemoViewType) as Window;
                    AssociatedObject.ShowcaseList.SelectedItem = null;

                    DemosNavigationService.MainWindow.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        sampleBrowserViewModel.IsShowCaseDemoBusy = false;
                    }),
                                                                             System.Windows.Threading.DispatcherPriority.ApplicationIdle);

                    if (window != null)
                    {
                        window.Owner = DemosNavigationService.MainWindow;
                        window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        window.Closed += Window_Closed;
                        window.ShowDialog();
                    }
                }
                catch (Exception exception)
                {
                    sampleBrowserViewModel.IsShowCaseDemoBusy = false;
                    ErrorWindow.Show(exception.Message + "\n" + exception.StackTrace);
                }
            }
        }