private async Task RunGenerator(int index)
        {
            DependencyObject registration = null;

            if (_treeGeneratorWindow == null)
            {
                registration = DialogParticipation.GetAssociation(this);
                DialogParticipation.SetRegister(registration, _treeGeneratorViewModel);
            }
            var generator = _treeGeneratorViewModel.Tabs[index];
            await _treeGeneratorViewModel.RunAsync(generator);

            if (registration != null)
            {
                DialogParticipation.SetRegister(registration, this);
            }
        }
예제 #2
0
        private static CrystalWindow GetCrystalWindow(object context)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (DialogParticipation.IsRegistered(context) == false)
            {
                throw new InvalidOperationException($"The context `{context}` is not registered. Consider using the DialogParticipation.Register property in XAML to bind in the DataContext.");
            }

            var association   = DialogParticipation.GetAssociation(context);
            var crystalWindow = association.Invoke(() => Window.GetWindow(association) as CrystalWindow);

            if (crystalWindow is null)
            {
                throw new InvalidOperationException($"The context `{context}` is not inside a CrystalWindow.");
            }

            return(crystalWindow);
        }