コード例 #1
0
        /// <summary>
        /// Creates the enum control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateEnumControl(PropertyItem property, PropertyControlFactoryOptions options)
        {
            var isRadioButton = true;
            var enumType      = TypeHelper.GetEnumType(property.Descriptor.PropertyType);
            var values        = Enum.GetValues(enumType);

            if (values.Length > options.EnumAsRadioButtonsLimit && !property.UseRadioButtons)
            {
                isRadioButton = false;
            }

            if (isRadioButton)
            {
                var c = new RadioButtonList {
                    EnumType = property.Descriptor.PropertyType
                };
                c.SetBinding(RadioButtonList.ValueProperty, property.CreateBinding());
                return(c);
            }
            else
            {
                var c = new ComboBox {
                    ItemsSource = Enum.GetValues(enumType)
                };
                c.SetBinding(Selector.SelectedValueProperty, property.CreateBinding());
                return(c);
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates the select control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="options">The options.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateEnumControl(
            PropertyItem property, PropertyControlFactoryOptions options)
        {
            // TODO: use check boxes for bit fields
            //// var isBitField = property.Descriptor.PropertyType.GetTypeInfo().GetCustomAttributes<FlagsAttribute>().Any();

            var values = this.GetEnumValues(property.Descriptor.PropertyType).ToArray();
            var style  = property.SelectorStyle;

            if (style == DataAnnotations.SelectorStyle.Auto)
            {
                style = values.Length > options.EnumAsRadioButtonsLimit
                            ? DataAnnotations.SelectorStyle.ComboBox
                            : DataAnnotations.SelectorStyle.RadioButtons;
            }

            switch (style)
            {
            case DataAnnotations.SelectorStyle.RadioButtons:
            {
                var c = new RadioButtonList {
                    EnumType = property.Descriptor.PropertyType
                };
                c.SetBinding(RadioButtonList.ValueProperty, property.CreateBinding());
                return(c);
            }

            case DataAnnotations.SelectorStyle.ComboBox:
            {
                var c = new ComboBox {
                    ItemsSource = values
                };
                c.SetBinding(Selector.SelectedValueProperty, property.CreateBinding());
                return(c);
            }

            case DataAnnotations.SelectorStyle.ListBox:
            {
                var c = new ListBox {
                    ItemsSource = values
                };
                c.SetBinding(Selector.SelectedValueProperty, property.CreateBinding());
                return(c);
            }

            default:
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates the slider control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateSliderControl(PropertyItem property)
        {
            var g = new Grid();

            g.ColumnDefinitions.Add(
                new System.Windows.Controls.ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            g.ColumnDefinitions.Add(
                new System.Windows.Controls.ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            var s = new Slider
            {
                Minimum             = property.SliderMinimum,
                Maximum             = property.SliderMaximum,
                SmallChange         = property.SliderSmallChange,
                LargeChange         = property.SliderLargeChange,
                TickFrequency       = property.SliderTickFrequency,
                IsSnapToTickEnabled = property.SliderSnapToTicks
            };

            s.SetBinding(RangeBase.ValueProperty, property.CreateBinding());
            g.Children.Add(s);

            var trigger = property.AutoUpdateText ? UpdateSourceTrigger.PropertyChanged : UpdateSourceTrigger.Default;
            var c       = new TextBox {
                IsReadOnly = property.Descriptor.IsReadOnly
            };

            var formatString = property.FormatString;

            if (formatString != null && !formatString.StartsWith("{"))
            {
                formatString = "{0:" + formatString + "}";
            }

            var binding = property.CreateBinding();

            binding.StringFormat        = formatString;
            binding.UpdateSourceTrigger = trigger;

            c.SetBinding(TextBox.TextProperty, binding);

            Grid.SetColumn(c, 1);
            g.Children.Add(c);

            return(g);
        }
コード例 #4
0
        /// <summary>
        /// Creates the color control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateColorControl(PropertyItem property)
        {
            var c = new ColorPicker2();

            c.SetBinding(ColorPicker2.SelectedColorProperty, property.CreateBinding());
            return(c);
        }
コード例 #5
0
        /// <summary>
        /// Creates the grid control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateGridControl(PropertyItem property)
        {
            var c = new DataGrid
            {
                CanDelete                     = property.ListCanRemove,
                CanInsert                     = property.ListCanAdd,
                InputDirection                = property.InputDirection,
                IsEasyInsertByMouseEnabled    = property.IsEasyInsertByMouseEnabled,
                IsEasyInsertByKeyboardEnabled = property.IsEasyInsertByKeyboardEnabled,
                AutoGenerateColumns           = property.Columns.Count == 0
            };

            foreach (var cd in property.Columns)
            {
                if (cd.PropertyName == string.Empty && property.ListItemItemsSource != null)
                {
                    cd.ItemsSource = property.ListItemItemsSource;
                }

                c.ColumnDefinitions.Add(cd);
            }

            c.SetBinding(DataGrid.ItemsSourceProperty, property.CreateBinding());
            return(c);
        }
コード例 #6
0
        /// <summary>
        /// Creates the HTML control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateHtmlControl(PropertyItem property)
        {
            var c = new WebBrowser();

            c.SetBinding(WebBrowserBehavior.NavigateToStringProperty, property.CreateBinding());
            return(c);
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
        /// <summary>
        /// Creates a dictionary control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateDictionaryControl(PropertyItem property)
        {
            var c = new ComboBox();

            c.SetBinding(ItemsControl.ItemsSourceProperty, property.CreateBinding());
            return(c);
        }
コード例 #9
0
        /// <summary>
        /// Creates the date time control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateDateTimeControl(PropertyItem property)
        {
            var c = new DatePicker();

            c.SetBinding(DatePicker.SelectedDateProperty, property.CreateBinding());
            return(c);
        }
コード例 #10
0
        /// <summary>
        /// Creates the brush control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateBrushControl(PropertyItem property)
        {
            var c = new ColorPicker();

            c.SetBinding(ColorPicker.SelectedColorProperty, property.CreateBinding());
            return(c);
        }
コード例 #11
0
        /// <summary>
        /// Creates the font family control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateFontFamilyControl(PropertyItem property)
        {
            var c = new ComboBox {
                ItemsSource = GetFontFamilies()
            };

            if (property.PreviewFonts)
            {
                var dt = new DataTemplate {
                    DataType = typeof(ComboBox)
                };
                var factory = new FrameworkElementFactory(typeof(TextBlock));
                factory.SetValue(TextBlock.FontSizeProperty, property.FontSize);
                factory.SetValue(TextBlock.FontWeightProperty, FontWeight.FromOpenTypeWeight(property.FontWeight));
                factory.SetBinding(TextBlock.TextProperty, new Binding());
                factory.SetBinding(TextBlock.FontFamilyProperty, new Binding {
                    Converter = FontFamilyConverter
                });
                dt.VisualTree  = factory;
                c.ItemTemplate = dt;
            }

            var binding = property.CreateBinding();

            if (property.ActualPropertyType == typeof(string))
            {
                binding.Converter = FontFamilyConverter;
            }

            c.SetBinding(Selector.SelectedValueProperty, binding);
            return(c);
        }
コード例 #12
0
        /// <summary>
        /// Creates the select control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="options">The options.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateEnumControl(
            PropertyItem property, PropertyControlFactoryOptions options)
        {
            var enumType = TypeHelper.GetEnumType(property.Descriptor.PropertyType);
            var values   = Enum.GetValues(enumType);
            var style    = property.SelectorStyle;

            if (style == DataAnnotations.SelectorStyle.Auto)
            {
                style = values.Length > options.EnumAsRadioButtonsLimit
                            ? DataAnnotations.SelectorStyle.ComboBox
                            : DataAnnotations.SelectorStyle.RadioButtons;
            }

            switch (style)
            {
            case DataAnnotations.SelectorStyle.RadioButtons:
            {
                var c = new RadioButtonList {
                    EnumType = property.Descriptor.PropertyType
                };
                c.SetBinding(RadioButtonList.ValueProperty, property.CreateBinding());
                return(c);
            }

            case DataAnnotations.SelectorStyle.ComboBox:
            {
                var c = new ComboBox {
                    ItemsSource = Enum.GetValues(enumType)
                };
                c.SetBinding(Selector.SelectedValueProperty, property.CreateBinding());
                return(c);
            }

            case DataAnnotations.SelectorStyle.ListBox:
            {
                var c = new ListBox {
                    ItemsSource = Enum.GetValues(enumType)
                };
                c.SetBinding(Selector.SelectedValueProperty, property.CreateBinding());
                return(c);
            }

            default:
                return(null);
            }
        }
コード例 #13
0
        /// <summary>
        /// Creates the password control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreatePasswordControl(PropertyItem property)
        {
            var c = new PasswordBox();

            PasswordHelper.SetAttach(c, true);
            c.SetBinding(PasswordHelper.PasswordProperty, property.CreateBinding());
            return(c);
        }
コード例 #14
0
        /// <summary>
        /// Creates the directory path control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateDirectoryPathControl(PropertyItem property)
        {
            var c = new DirectoryPicker {
                FolderBrowserDialogService = this.FolderBrowserDialogService
            };

            c.SetBinding(DirectoryPicker.DirectoryProperty, property.CreateBinding());
            return(c);
        }
コード例 #15
0
        /// <summary>
        /// Creates the directory path control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateDirectoryPathControl(PropertyItem property)
        {
            var c = new DirectoryPicker {
                FolderBrowserDialogService = this.FolderBrowserDialogService
            };
            var trigger = property.AutoUpdateText ? UpdateSourceTrigger.PropertyChanged : UpdateSourceTrigger.Default;

            c.SetBinding(DirectoryPicker.DirectoryProperty, property.CreateBinding(trigger));
            return(c);
        }
コード例 #16
0
        /// <summary>
        /// Creates the bool control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateBoolControl(PropertyItem property)
        {
            var c = new CheckBox
            {
                VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left
            };

            c.SetBinding(ToggleButton.IsCheckedProperty, property.CreateBinding());
            return(c);
        }
コード例 #17
0
        /// <summary>
        /// Creates the link control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateLinkControl(PropertyItem property)
        {
            var c = new LinkBlock {
                VerticalAlignment = VerticalAlignment.Center
            };

            c.SetBinding(TextBlock.TextProperty, new Binding(property.Descriptor.Name));
            c.SetBinding(LinkBlock.NavigateUriProperty, property.CreateBinding());
            return(c);
        }
コード例 #18
0
        /// <summary>
        /// Creates the spin control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateSpinControl(PropertyItem property)
        {
            var tb = new TextBox
            {
                BorderThickness = new Thickness(0), HorizontalContentAlignment = HorizontalAlignment.Right
            };

            tb.SetBinding(TextBox.TextProperty, property.CreateBinding());
            var c = new SpinControl
            {
                Maximum     = property.SpinMaximum,
                Minimum     = property.SpinMinimum,
                SmallChange = property.SpinSmallChange,
                LargeChange = property.SpinLargeChange,
                Content     = tb
            };

            c.SetBinding(SpinControl.ValueProperty, property.CreateBinding());
            return(c);
        }
コード例 #19
0
        /// <summary>
        /// Creates the checkbox control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateBoolControl(PropertyItem property)
        {
            if (property.Descriptor.IsReadOnly())
            {
                var cm = new CheckMark
                {
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Left
                };
                cm.SetBinding(CheckMark.IsCheckedProperty, property.CreateBinding());
                return(cm);
            }

            var c = new CheckBox
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            c.SetBinding(ToggleButton.IsCheckedProperty, property.CreateBinding());
            return(c);
        }
コード例 #20
0
        /// <summary>
        /// Creates a content control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// A <see cref="ContentControl" />.
        /// </returns>
        protected virtual FrameworkElement CreateContentControl(PropertyItem property)
        {
            var b = new ContentControl
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                Margin    = new Thickness(4),
                Focusable = false,
                HorizontalContentAlignment = HorizontalAlignment.Stretch
            };

            b.SetBinding(ContentControl.ContentProperty, property.CreateBinding());
            return(b);
        }
コード例 #21
0
        /// <summary>
        /// Creates the grid control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateGridControl(PropertyItem property)
        {
            var c = new DataGrid
            {
                CanDelete           = property.ListCanRemove,
                CanInsert           = property.ListCanAdd,
                InputDirection      = property.InputDirection,
                EasyInsert          = property.EasyInsert,
                AutoGenerateColumns = property.Columns.Count == 0
            };

            var glc = new GridLengthConverter();

            foreach (var ca in property.Columns.OrderBy(cd => cd.ColumnIndex))
            {
                var cd = new ColumnDefinition
                {
                    PropertyName = ca.PropertyName,
                    Header       = ca.Header,
                    FormatString = ca.FormatString,
                    Width        = (GridLength)(glc.ConvertFromInvariantString(ca.Width) ?? GridLength.Auto),
                    IsReadOnly   = ca.IsReadOnly
                };

                if (ca.PropertyName == string.Empty && property.ListItemItemsSource != null)
                {
                    cd.ItemsSource = property.ListItemItemsSource;
                }

                switch (ca.Alignment.ToString(CultureInfo.InvariantCulture).ToUpper())
                {
                case "L":
                    cd.HorizontalAlignment = HorizontalAlignment.Left;
                    break;

                case "R":
                    cd.HorizontalAlignment = HorizontalAlignment.Right;
                    break;

                default:
                    cd.HorizontalAlignment = HorizontalAlignment.Center;
                    break;
                }

                c.ColumnDefinitions.Add(cd);
            }

            c.SetBinding(DataGrid.ItemsSourceProperty, property.CreateBinding());
            return(c);
        }
コード例 #22
0
        /// <summary>
        /// Creates a comment control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateCommentControl(PropertyItem property)
        {
            var tb = new TextBlock
            {
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(4),
                Focusable         = false,
                TextWrapping      = TextWrapping.Wrap
            };

            ScrollViewer.SetHorizontalScrollBarVisibility(tb, ScrollBarVisibility.Hidden);
            ScrollViewer.SetVerticalScrollBarVisibility(tb, ScrollBarVisibility.Hidden);
            tb.SetBinding(TextBlock.TextProperty, property.CreateBinding());
            return(tb);
        }
コード例 #23
0
        /// <summary>
        /// Creates the spin control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateSpinControl(PropertyItem property)
        {
            var tb = new TextBoxEx
            {
                IsReadOnly                 = property.IsReadOnly,
                BorderThickness            = new Thickness(0),
                HorizontalContentAlignment = ConvertHorizontalAlignment(property.HorizontalAlignment),
                VerticalContentAlignment   = VerticalAlignment.Center
            };

            tb.SetBinding(TextBox.TextProperty, property.CreateBinding());
            var c = new SpinControl
            {
                Maximum     = property.SpinMaximum,
                Minimum     = property.SpinMinimum,
                SmallChange = property.SpinSmallChange,
                LargeChange = property.SpinLargeChange,
                Content     = tb
            };

            // Note: Do not apply the converter to the SpinControl
            c.SetBinding(SpinControl.ValueProperty, property.CreateBinding(UpdateSourceTrigger.Default, false));
            return(c);
        }
コード例 #24
0
        /// <summary>
        /// Creates the default control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateDefaultControl(PropertyItem property)
        {
            // TextBox is the default control
            var trigger = property.AutoUpdateText ? UpdateSourceTrigger.PropertyChanged : UpdateSourceTrigger.Default;
            var c       = new TextBox
            {
                AcceptsReturn = property.AcceptsReturn,
                MaxLength     = property.MaxLength,
                IsReadOnly    = property.Descriptor.IsReadOnly,
                TextWrapping  = property.TextWrapping,
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto
            };

            c.SetBinding(TextBox.TextProperty, property.CreateBinding(trigger));
            return(c);
        }
コード例 #25
0
        /// <summary>
        /// Creates a sequence of checkboxes.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// A FrameworkElement.
        /// </returns>
        protected virtual FrameworkElement CreateCheckableItems(PropertyItem property)
        {
            var lb = new ItemsControl();
            var rectangleFactory = new FrameworkElementFactory(typeof(CheckBox));

            rectangleFactory.SetBinding(ToggleButton.IsCheckedProperty, new Binding(property.CheckableItemsIsCheckedPropertyName));
            rectangleFactory.SetBinding(ContentControl.ContentProperty, new Binding(property.CheckableItemsContentPropertyName));

            lb.ItemTemplate = new DataTemplate {
                VisualTree = rectangleFactory
            };
            lb.SetBinding(ItemsControl.ItemsSourceProperty, property.CreateBinding());
            lb.Margin = new Thickness(0, 6, 0, 6);

            return(lb);
        }
コード例 #26
0
        /// <summary>
        /// Creates the default control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateDefaultControl(PropertyItem property)
        {
            // TextBox is the default control
            var trigger = property.AutoUpdateText ? UpdateSourceTrigger.PropertyChanged : UpdateSourceTrigger.Default;
            var c       = new TextBoxEx
            {
                AcceptsReturn = property.AcceptsReturn,
                MaxLength     = property.MaxLength,
                IsReadOnly    = property.IsReadOnly,
                TextWrapping  = property.TextWrapping,
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                VerticalContentAlignment    = property.AcceptsReturn ? VerticalAlignment.Top : VerticalAlignment.Center
            };

            if (property.FontFamily != null)
            {
                c.FontFamily = new FontFamily(property.FontFamily);
            }

            if (!double.IsNaN(property.FontSize))
            {
                c.FontSize = property.FontSize;
            }

            if (property.IsReadOnly)
            {
                // c.Opacity = 0.8;
                c.Foreground = Brushes.RoyalBlue;
            }

            var binding = property.CreateBinding(trigger);

            if (property.ActualPropertyType != typeof(string) && IsNullable(property.ActualPropertyType))
            {
                // Empty values should set the source to null
                // Set the value that is used in the target when the value of the source is null.
                binding.TargetNullValue = string.Empty;
            }

            c.SetBinding(TextBox.TextProperty, binding);

            return(c);
        }
コード例 #27
0
        /// <summary>
        /// Creates the grid control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateGridControl(PropertyItem property)
        {
            var c = new SimpleGrid {
                CanDelete = property.ListCanRemove, CanInsert = property.ListCanAdd
            };

            var glc = new GridLengthConverter();

            foreach (var ca in property.Columns.OrderBy(cd => cd.ColumnIndex))
            {
                var cd = new ColumnDefinition
                {
                    DataField    = ca.PropertyName,
                    Header       = ca.Header,
                    FormatString = ca.FormatString,
                    Width        = (GridLength)glc.ConvertFromInvariantString(ca.Width)
                };
                switch (ca.Alignment.ToString().ToUpper())
                {
                case "L":
                    cd.HorizontalAlignment = HorizontalAlignment.Left;
                    break;

                case "R":
                    cd.HorizontalAlignment = HorizontalAlignment.Right;
                    break;

                default:
                    cd.HorizontalAlignment = HorizontalAlignment.Center;
                    break;
                }

                c.ColumnDefinitions.Add(cd);
            }

            c.SetBinding(SimpleGrid.ContentProperty, property.CreateBinding());
            return(c);
        }
コード例 #28
0
        /// <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);
        }
コード例 #29
0
        /// <summary>
        /// Creates the combo box control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// The control.
        /// </returns>
        protected virtual FrameworkElement CreateComboBoxControl(PropertyItem property)
        {
            var c = new ComboBox {
                IsEditable = property.IsEditable, ItemsSource = property.ItemsSource, VerticalContentAlignment = VerticalAlignment.Center
            };

            if (property.ItemsSourceDescriptor != null)
            {
                c.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(property.ItemsSourceDescriptor.Name));
            }

            c.SelectedValuePath = property.SelectedValuePath;
            c.DisplayMemberPath = property.DisplayMemberPath;

            c.SetBinding(property.IsEditable ? ComboBox.TextProperty : Selector.SelectedValueProperty, property.CreateBinding());

            return(c);
        }
コード例 #30
0
        /// <summary>
        /// Creates the combo box control.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <returns>
        /// The control.
        /// </returns>
        protected FrameworkElement CreateComboBoxControl(PropertyItem property)
        {
            var c = new ComboBox {
                IsEditable = property.IsEditable
            };

            c.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(property.ItemsSourceDescriptor.Name));

            c.SetBinding(
                property.IsEditable ? ComboBox.TextProperty : Selector.SelectedValueProperty, property.CreateBinding());

            return(c);
        }