From 3b3e10da100693cc7b8e13d787575c406821a147 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Fri, 7 Oct 2011 17:12:31 +0000 Subject: [PATCH] PropertyGrid: Added PropertyGrid examples to the Samples application. --- .../PropertyGridModule.cs | 5 + .../Resources/LastNameUserControlEditor.xaml | 9 + .../LastNameUserControlEditor.xaml.cs | 39 +++++ .../Samples.Modules.PropertyGrid.csproj | 42 +++++ .../Views/CustomEditors.xaml | 70 ++++++++ .../Views/CustomEditors.xaml.cs | 157 ++++++++++++++++++ .../Views/CustomItemsSource.xaml | 23 +++ .../Views/CustomItemsSource.xaml.cs | 80 +++++++++ .../Views/DefaultEditors.xaml | 21 +++ .../Views/DefaultEditors.xaml.cs | 104 ++++++++++++ .../Views/ExpandableProperties.xaml | 23 +++ .../Views/ExpandableProperties.xaml.cs | 62 +++++++ .../Views/HomeView.xaml | 65 +++++++- .../Views/HomeView.xaml.cs | 3 +- .../Views/NavigationView.xaml | 10 ++ .../Views/SpecifyingProperties.xaml | 30 ++++ .../Views/SpecifyingProperties.xaml.cs | 104 ++++++++++++ .../Implementation/IEditorDefinition.cs | 12 -- .../Implementation/PropertyItem.cs | 4 +- 19 files changed, 844 insertions(+), 19 deletions(-) create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml.cs create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml.cs create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml.cs create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml.cs create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml.cs create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/SpecifyingProperties.xaml create mode 100644 ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/SpecifyingProperties.xaml.cs delete mode 100644 ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/IEditorDefinition.cs diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/PropertyGridModule.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/PropertyGridModule.cs index 00a102e6..e97d9ae0 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/PropertyGridModule.cs +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/PropertyGridModule.cs @@ -20,6 +20,11 @@ namespace Samples.Modules.PropertyGrid protected override void RegisterViewsAndTypes() { Container.RegisterNavigationType(typeof(HomeView)); + Container.RegisterNavigationType(typeof(CustomEditors)); + Container.RegisterNavigationType(typeof(CustomItemsSource)); + Container.RegisterNavigationType(typeof(DefaultEditors)); + Container.RegisterNavigationType(typeof(ExpandableProperties)); + Container.RegisterNavigationType(typeof(SpecifyingProperties)); } } } diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml new file mode 100644 index 00000000..f2747400 --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml @@ -0,0 +1,9 @@ + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml.cs new file mode 100644 index 00000000..b5dab36f --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml.cs @@ -0,0 +1,39 @@ +using System.Windows; +using System.Windows.Controls; +using Microsoft.Windows.Controls.PropertyGrid.Editors; +using System.Windows.Data; + +namespace Samples.Modules.PropertyGrid +{ + /// + /// Interaction logic for LastNameUserControlEditor.xaml + /// + public partial class LastNameUserControlEditor : UserControl, ITypeEditor + { + public LastNameUserControlEditor() + { + InitializeComponent(); + } + + public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(string), typeof(LastNameUserControlEditor), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + public string Value + { + get { return (string)GetValue(ValueProperty); } + set { SetValue(ValueProperty, value); } + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + Value = string.Empty; + } + + public FrameworkElement ResolveEditor(Microsoft.Windows.Controls.PropertyGrid.PropertyItem propertyItem) + { + Binding binding = new Binding("Value"); + binding.Source = propertyItem; + binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay; + BindingOperations.SetBinding(this, LastNameUserControlEditor.ValueProperty, binding); + return this; + } + } +} diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Samples.Modules.PropertyGrid.csproj b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Samples.Modules.PropertyGrid.csproj index aa335640..a6ac0113 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Samples.Modules.PropertyGrid.csproj +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Samples.Modules.PropertyGrid.csproj @@ -61,6 +61,9 @@ + + LastNameUserControlEditor.xaml + Code @@ -75,12 +78,27 @@ Settings.settings True + + CustomEditors.xaml + + + CustomItemsSource.xaml + + + DefaultEditors.xaml + + + ExpandableProperties.xaml + HomeView.xaml NavigationView.xaml + + SpecifyingProperties.xaml + ResXFileCodeGenerator Resources.Designer.cs @@ -102,6 +120,26 @@ + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -110,6 +148,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml new file mode 100644 index 00000000..d359c568 --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml.cs new file mode 100644 index 00000000..4487e474 --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml.cs @@ -0,0 +1,157 @@ +using Samples.Infrastructure.Controls; +using System.ComponentModel; +using System.Collections.Generic; +using System; +using System.Windows; +using System.Windows.Media; +using System.Windows.Controls; +using System.Windows.Data; + +namespace Samples.Modules.PropertyGrid.Views +{ + /// + /// Interaction logic for CustomEditors.xaml + /// + public partial class CustomEditors : DemoView + { + public CustomEditors() + { + InitializeComponent(); + _propertyGrid1.SelectedObject = Person.CreatePerson(); + _propertyGrid2.SelectedObject = CustomAttributEditorPerson.CreateCustomAttributEditorPerson(); + } + + public class Person + { + [Category("Information")] + [DisplayName("First Name")] + [Description("This property uses a TextBox as the default editor.")] + public string FirstName { get; set; } + + [Category("Information")] + [DisplayName("Last Name")] + [Description("This property uses a TextBox as the default editor.")] + public string LastName { get; set; } + + [Category("Information")] + [DisplayName("Date of Birth")] + [Description("This property uses the DateTimeUpDown as the default editor.")] + public DateTime DateOfBirth { get; set; } + + [DisplayName("Grade Point Average")] + [Description("This property uses the DoubleUpDown as the default editor.")] + public double GradePointAvg { get; set; } + + [Category("Information")] + [Description("This property uses the IntegerUpDown as the default editor.")] + public int Age { get; set; } + + [Category("Information")] + [DisplayName("Is Male")] + [Description("This property uses a CheckBox as the default editor.")] + public bool IsMale { get; set; } + + [Category("Information")] + [DisplayName("Favorite Color")] + [Description("This property uses the ColorPicker as the default editor.")] + public Color FavoriteColor { get; set; } + + [Category("Writing")] + [DisplayName("Writing Hand")] + [Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] + public HorizontalAlignment WritingHand { get; set; } + + [Category("Writing")] + [DisplayName("Writing Font")] + [Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] + public FontFamily WritingFont { get; set; } + + [Category("Writing")] + [DisplayName("Writing Font Size")] + [Description("This property uses the DoubleUpDown as the default editor.")] + public double WritingFontSize { get; set; } + + [Category("Conections")] + [DisplayName("Pet Names")] + [Description("This property uses the PrimitiveTypeCollectionEditor as the default editor.")] + public List PetNames { get; set; } + + [Category("Conections")] + [Description("This property uses the CollectionEditor as the default editor.")] + public List Friends { get; set; } + + [Category("Conections")] + [Description("This property is a complex property and has no default editor.")] + public Person Spouse { get; set; } + + public static Person CreatePerson() + { + var person = new Person(); + person.FirstName = "John"; + person.LastName = "Doe"; + person.DateOfBirth = new DateTime(1975, 1, 23); + person.Age = DateTime.Today.Year - person.DateOfBirth.Year; + person.GradePointAvg = 3.98; + person.IsMale = true; + person.FavoriteColor = Colors.Blue; + person.WritingHand = System.Windows.HorizontalAlignment.Right; + person.WritingFont = new FontFamily("Arial"); + person.WritingFontSize = 12.5; + person.PetNames = new List() { "Pet 1", "Pet 2", "Pet 3" }; + person.Friends = new List() { new Person() { FirstName = "First", LastName = "Friend" }, new Person() { FirstName = "Second", LastName = "Friend" } }; + person.Spouse = new Person() { FirstName = "Jane", LastName = "Doe" }; + return person; + } + } + + public class CustomAttributEditorPerson + { + [Category("Information")] + [DisplayName("First Name")] + [Description("This property uses a TextBox as the default editor.")] + //This custom editor is a Class that implements the ITypeEditor interface + [Editor(typeof(FirstNameEditor), typeof(FirstNameEditor))] + public string FirstName { get; set; } + + [Category("Information")] + [DisplayName("Last Name")] + [Description("This property uses a TextBox as the default editor.")] + //This custom editor is a UserControl that implements the ITypeEditor interface + [Editor(typeof(LastNameUserControlEditor), typeof(LastNameUserControlEditor))] + public string LastName { get; set; } + + [Category("Information")] + [DisplayName("Date of Birth")] + [Description("This property uses the DateTimeUpDown as the default editor.")] + public DateTime DateOfBirth { get; set; } + + public static CustomAttributEditorPerson CreateCustomAttributEditorPerson() + { + var person = new CustomAttributEditorPerson(); + person.FirstName = "John"; + person.LastName = "Doe"; + person.DateOfBirth = new DateTime(1975, 1, 23); + return person; + } + } + } + + //Custom editors that are used as attributes MUST implement the ITypeEditor interface. + public class FirstNameEditor : Microsoft.Windows.Controls.PropertyGrid.Editors.ITypeEditor + { + public FrameworkElement ResolveEditor(Microsoft.Windows.Controls.PropertyGrid.PropertyItem propertyItem) + { + TextBox textBox = new TextBox(); + textBox.Background = new SolidColorBrush(Colors.Red); + + //create the binding from the bound property item to the editor + var _binding = new Binding("Value"); //bind to the Value property of the PropertyItem + _binding.Source = propertyItem; + _binding.ValidatesOnExceptions = true; + _binding.ValidatesOnDataErrors = true; + _binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay; + BindingOperations.SetBinding(textBox, TextBox.TextProperty, _binding); + return textBox; + } + } +} diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml new file mode 100644 index 00000000..56e7e5ae --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml.cs new file mode 100644 index 00000000..e25dc887 --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml.cs @@ -0,0 +1,80 @@ +using Samples.Infrastructure.Controls; +using System.ComponentModel; +using System.Collections.Generic; +using System; +using System.Windows.Media; +using System.Windows; +using Microsoft.Windows.Controls.PropertyGrid.Attributes; + +namespace Samples.Modules.PropertyGrid.Views +{ + /// + /// Interaction logic for CustomItemsSource.xaml + /// + public partial class CustomItemsSource : DemoView + { + public CustomItemsSource() + { + InitializeComponent(); + _propertyGrid.SelectedObject = Person.CreatePerson(); + } + + public class Person + { + [Category("Information")] + [DisplayName("First Name")] + [Description("This property uses a TextBox as the default editor.")] + public string FirstName { get; set; } + + [Category("Information")] + [DisplayName("Last Name")] + [Description("This property uses a TextBox as the default editor.")] + public string LastName { get; set; } + + [Category("Information")] + [DisplayName("Date of Birth")] + [Description("This property uses the DateTimeUpDown as the default editor.")] + public DateTime DateOfBirth { get; set; } + + [Category("Writing")] + [DisplayName("Writing Hand")] + [Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] + public HorizontalAlignment WritingHand { get; set; } + + [Category("Writing")] + [DisplayName("Writing Font")] + [Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] + public FontFamily WritingFont { get; set; } + + [Category("Writing")] + [DisplayName("Writing Font Size")] + [Description("This property uses the DoubleUpDown as the default editor.")] + [ItemsSource(typeof(FontSizeItemsSource))] + public double WritingFontSize { get; set; } + + public static Person CreatePerson() + { + var person = new Person(); + person.FirstName = "John"; + person.LastName = "Doe"; + person.DateOfBirth = new DateTime(1975, 1, 23); + person.WritingHand = System.Windows.HorizontalAlignment.Right; + person.WritingFont = new FontFamily("Arial"); + person.WritingFontSize = 12.0; + return person; + } + } + } + + public class FontSizeItemsSource : IItemsSource + { + public IList GetValues() + { + List sizes = new List() + { + 5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,12.0,14.0,16.0,18.0,20.0 + }; + return sizes; + } + } +} diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml new file mode 100644 index 00000000..254903ff --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml.cs new file mode 100644 index 00000000..0e75c54c --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml.cs @@ -0,0 +1,104 @@ +using Samples.Infrastructure.Controls; +using System; +using System.Collections.Generic; +using System.Windows.Media; +using System.ComponentModel; +using System.Windows; + +namespace Samples.Modules.PropertyGrid.Views +{ + /// + /// Interaction logic for DefaultEditors.xaml + /// + public partial class DefaultEditors : DemoView + { + public DefaultEditors() + { + InitializeComponent(); + _propertyGrid.SelectedObject = Person.CreatePerson(); + } + + public class Person + { + [Category("Information")] + [DisplayName("First Name")] + [Description("This property uses a TextBox as the default editor.")] + public string FirstName { get; set; } + + [Category("Information")] + [DisplayName("Last Name")] + [Description("This property uses a TextBox as the default editor.")] + public string LastName { get; set; } + + [Category("Information")] + [DisplayName("Date of Birth")] + [Description("This property uses the DateTimeUpDown as the default editor.")] + public DateTime DateOfBirth { get; set; } + + [DisplayName("Grade Point Average")] + [Description("This property uses the DoubleUpDown as the default editor.")] + public double GradePointAvg { get; set; } + + [Category("Information")] + [Description("This property uses the IntegerUpDown as the default editor.")] + public int Age { get; set; } + + [Category("Information")] + [DisplayName("Is Male")] + [Description("This property uses a CheckBox as the default editor.")] + public bool IsMale { get; set; } + + [Category("Information")] + [DisplayName("Favorite Color")] + [Description("This property uses the ColorPicker as the default editor.")] + public Color FavoriteColor { get; set; } + + [Category("Writing")] + [DisplayName("Writing Hand")] + [Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] + public HorizontalAlignment WritingHand { get; set; } + + [Category("Writing")] + [DisplayName("Writing Font")] + [Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] + public FontFamily WritingFont { get; set; } + + [Category("Writing")] + [DisplayName("Writing Font Size")] + [Description("This property uses the DoubleUpDown as the default editor.")] + public double WritingFontSize { get; set; } + + [Category("Conections")] + [DisplayName("Pet Names")] + [Description("This property uses the PrimitiveTypeCollectionEditor as the default editor.")] + public List PetNames { get; set; } + + [Category("Conections")] + [Description("This property uses the CollectionEditor as the default editor.")] + public List Friends { get; set; } + + [Category("Conections")] + [Description("This property is a complex property and has no default editor.")] + public Person Spouse { get; set; } + + public static Person CreatePerson() + { + var person = new Person(); + person.FirstName = "John"; + person.LastName = "Doe"; + person.DateOfBirth = new DateTime(1975, 1, 23); + person.Age = DateTime.Today.Year - person.DateOfBirth.Year; + person.GradePointAvg = 3.98; + person.IsMale = true; + person.FavoriteColor = Colors.Blue; + person.WritingHand = System.Windows.HorizontalAlignment.Right; + person.WritingFont = new FontFamily("Arial"); + person.WritingFontSize = 12.5; + person.PetNames = new List() { "Pet 1", "Pet 2", "Pet 3" }; + person.Friends = new List() { new Person() { FirstName = "First", LastName = "Friend" }, new Person() { FirstName = "Second", LastName = "Friend" } }; + person.Spouse = new Person() { FirstName = "Jane", LastName = "Doe" }; + return person; + } + } + } +} diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml new file mode 100644 index 00000000..a9d0f8aa --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml.cs new file mode 100644 index 00000000..8012ff47 --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml.cs @@ -0,0 +1,62 @@ +using Samples.Infrastructure.Controls; +using System.ComponentModel; +using System.Collections.Generic; +using System; +using System.Windows.Media; +using System.Windows; +using Microsoft.Windows.Controls.PropertyGrid.Attributes; + +namespace Samples.Modules.PropertyGrid.Views +{ + /// + /// Interaction logic for ExpandableProperties.xaml + /// + public partial class ExpandableProperties : DemoView + { + public ExpandableProperties() + { + InitializeComponent(); + _propertyGrid.SelectedObject = Person.CreatePerson(); + } + + public class Person + { + [Category("Information")] + [DisplayName("First Name")] + [Description("This property uses a TextBox as the default editor.")] + public string FirstName { get; set; } + + [Category("Information")] + [DisplayName("Last Name")] + [Description("This property uses a TextBox as the default editor.")] + public string LastName { get; set; } + + [Category("Writing")] + [DisplayName("Writing Font")] + [Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] + public FontFamily WritingFont { get; set; } + + [Category("Writing")] + [DisplayName("Writing Font Size")] + [Description("This property uses the DoubleUpDown as the default editor.")] + public double WritingFontSize { get; set; } + + + [Category("Conections")] + [Description("This property is a complex property and has no default editor.")] + [ExpandableObject] + public Person Spouse { get; set; } + + public static Person CreatePerson() + { + var person = new Person(); + person.FirstName = "John"; + person.LastName = "Doe"; + person.WritingFont = new FontFamily("Arial"); + person.WritingFontSize = 12.5; + person.Spouse = new Person() { FirstName = "Jane", LastName = "Doe" }; + return person; + } + } + } +} diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml index 6b8d23d4..b9644796 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml @@ -2,8 +2,67 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" - Title="PropertyGrid" > - - + xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" + Title="PropertyGrid" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs index da6c5c79..3d54519d 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs @@ -1,6 +1,5 @@ -using System; +using Microsoft.Practices.Prism.Regions; using Samples.Infrastructure.Controls; -using Microsoft.Practices.Prism.Regions; namespace Samples.Modules.PropertyGrid.Views { diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/NavigationView.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/NavigationView.xaml index 85d97cf2..96bd94a3 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/NavigationView.xaml +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/NavigationView.xaml @@ -8,4 +8,14 @@