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

            e.Resource = ResourceSelectorWindow.RequestResource(panel, pvm.TargetPlatform.ResourceProvider, pvm.Editors.Select(ed => ed.Target), pvm.Property, e.Resource);
        }
Exemplo n.º 2
0
        private void OnResourceRequested(object sender, ResourceRequestedEventArgs e)
        {
            var panel = this.FindParent <PropertyEditorPanel> ();
            var vm    = ((PropertyViewModel)DataContext);

            e.Resource = ResourceSelectorWindow.RequestResource(panel, vm.ResourceProvider, vm.Editors.Select(ed => ed.Target), vm.Property, e.Resource);
        }
        internal static Resource RequestResource(FrameworkElement owner, IResourceProvider provider, IEnumerable <object> targets, IPropertyInfo property, Resource currentValue)
        {
            Window hostWindow = Window.GetWindow(owner);

            var w = new ResourceSelectorWindow(owner.Resources.MergedDictionaries, provider, targets, property)
            {
                Owner = hostWindow,
                list  =
                {
                    SelectedItem = currentValue
                }
            };

            if (!w.ShowDialog() ?? false)
            {
                return(null);
            }

            return(w.list.SelectedItem as Resource);
        }