コード例 #1
0
        public TemplateMetaData ShowUiAndGetTemplate(TemplateMetaData[] templates)
        {
            var templatesViewModel = templates
                .Select(t => new TemplateViewModel {DisplayName = t.Name, FullName = t.FullName})
                .ToArray();

            var selectTemplateViewModel = new SelectTemplateViewModel
            {
                Templates = templatesViewModel,
                SelectedTemplate = templatesViewModel.First()
            };

            var showDialogResult = new SelectTemplateWindow(selectTemplateViewModel).ShowDialog();

            return (showDialogResult ?? false)
                ? templates.First(t => t.FullName == selectTemplateViewModel.SelectedTemplate.FullName)
                : null;
        }
        public SelectTemplateWindow(SelectTemplateViewModel viewModel)
        {
            InitializeComponent();

            DataContext = viewModel;
        }