Пример #1
0
        private UIElement GetActionContent(BackupAction backupAction)
        {
            Uri actionContentUri   = new Uri($"pack://application:,,,/Windows/BackupActions/{backupAction.ToString()}BackupActionContent.xaml", UriKind.Absolute);
            var resourceStreamInfo = Application.GetResourceStream(actionContentUri);
            //TODO investigate LoadAsync but no awaiter implemented...
            // It seems because I have not applied the `x:SynchronouseMode="Async"` attribute to the root element of my xaml, it is being loaded synchronously. However this is good because If I was loading
            // it asyncrhonously, I would have to use the LoadCompleted event or otherwise my attaching of event handlers would be in trouble...
            // var xamlReader = new XamlReader();
            var uiElement = XamlReader.Load(resourceStreamInfo.Stream) as UIElement;

            AttachEventHandlersAndDataBinding(uiElement, backupAction);
            return(uiElement);
        }