Exemplo n.º 1
0
 private FrameworkElement CreateFilePicker(PropertyDefinition property, int index)
 {
     var c = new FilePicker
     {
         Filter = "Image Files (*.jpg, *.png)|*.jpg;*.png",
         UseOpenDialog = true,
     };
     c.SetBinding(FilePicker.FilePathProperty, property.CreateBinding(index));
     return c;
 }
        /// <summary>
        /// Creates the file path control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateFilePathControl(PropertyItem property)
        {
            var c = new FilePicker
                {
                    Filter = property.FilePathFilter,
                    DefaultExtension = property.FilePathDefaultExtension,
                    UseOpenDialog = property.IsFileOpenDialog,
                    FileDialogService = this.FileDialogService
                };
            if (property.RelativePathDescriptor != null)
            {
                c.SetBinding(FilePicker.BasePathProperty, new Binding(property.RelativePathDescriptor.Name));
            }

            if (property.FilterDescriptor != null)
            {
                c.SetBinding(FilePicker.FilterProperty, new Binding(property.FilterDescriptor.Name));
            }

            if (property.DefaultExtensionDescriptor != null)
            {
                c.SetBinding(FilePicker.DefaultExtensionProperty, new Binding(property.DefaultExtensionDescriptor.Name));
            }

            var trigger = property.AutoUpdateText ? UpdateSourceTrigger.PropertyChanged : UpdateSourceTrigger.Default;
            c.SetBinding(FilePicker.FilePathProperty, property.CreateBinding(trigger));
            return c;
        }
        /// <summary>
        /// Creates the file path control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateFilePathControl(PropertyItem property)
        {
            var c = new FilePicker
                {
                    Filter = property.FilePathFilter,
                    DefaultExtension = property.FilePathDefaultExtension,
                    UseOpenDialog = property.IsFileOpenDialog,
                    FileDialogService = this.FileDialogService
                };
            if (property.RelativePathDescriptor != null)
            {
                c.SetBinding(FilePicker.BasePathProperty, new Binding(property.RelativePathDescriptor.Name));
            }

            if (property.FilterDescriptor != null)
            {
                c.SetBinding(FilePicker.FilterProperty, new Binding(property.FilterDescriptor.Name));
            }

            c.SetBinding(FilePicker.FilePathProperty, property.CreateBinding());
            return c;
        }