Exemplo n.º 1
0
        private void OnCreateResourceRequested(object sender, CreateResourceRequestedEventArgs e)
        {
            var panel = this.FindPropertiesHost();
            var pvm   = (PropertyViewModel)DataContext;

            var result = CreateResourceWindow.CreateResource(panel, pvm.TargetPlatform.ResourceProvider, pvm.Editors.Select(oe => oe.Target), pvm.Property);

            e.Source = result.Item1;
            e.Name   = result.Item2;
        }
        internal static Tuple <ResourceSource, string> CreateResource(FrameworkElement owner, IResourceProvider provider, IEnumerable <object> targets, IPropertyInfo property)
        {
            Window ownerWindow = Window.GetWindow(owner);
            var    window      = new CreateResourceWindow(owner.Resources.MergedDictionaries, provider, targets, property)
            {
                Owner = ownerWindow
            };

            bool?result = window.ShowDialog();

            var vm = (CreateResourceViewModel)window.DataContext;

            if (result.HasValue && result.Value)
            {
                return(new Tuple <ResourceSource, string> (vm.SelectedResourceSource, vm.ResourceKey));
            }
            else
            {
                return(new Tuple <ResourceSource, string> (null, null));
            }
        }