@ -8,6 +8,7 @@ using System.Windows.Controls.Primitives;
using System.Windows.Data ;
using System.Windows.Data ;
using System.Windows.Input ;
using System.Windows.Input ;
using Microsoft.Windows.Controls.PropertyGrid.Commands ;
using Microsoft.Windows.Controls.PropertyGrid.Commands ;
using System.Reflection ;
namespace Microsoft.Windows.Controls.PropertyGrid
namespace Microsoft.Windows.Controls.PropertyGrid
{
{
@ -33,6 +34,17 @@ namespace Microsoft.Windows.Controls.PropertyGrid
#endregion //AdvancedOptionsMenu
#endregion //AdvancedOptionsMenu
#region AutoGenerateProperties
public static readonly DependencyProperty AutoGeneratePropertiesProperty = DependencyProperty . Register ( "AutoGenerateProperties" , typeof ( bool ) , typeof ( PropertyGrid ) , new UIPropertyMetadata ( true ) ) ;
public bool AutoGenerateProperties
{
get { return ( bool ) GetValue ( AutoGeneratePropertiesProperty ) ; }
set { SetValue ( AutoGeneratePropertiesProperty , value ) ; }
}
#endregion //AutoGenerateProperties
#region DisplaySummary
#region DisplaySummary
public static readonly DependencyProperty DisplaySummaryProperty = DependencyProperty . Register ( "DisplaySummary" , typeof ( bool ) , typeof ( PropertyGrid ) , new UIPropertyMetadata ( true ) ) ;
public static readonly DependencyProperty DisplaySummaryProperty = DependencyProperty . Register ( "DisplaySummary" , typeof ( bool ) , typeof ( PropertyGrid ) , new UIPropertyMetadata ( true ) ) ;
@ -46,7 +58,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid
#region EditorDefinitions
#region EditorDefinitions
public static readonly DependencyProperty EditorDefinitionsProperty = DependencyProperty . Register ( "EditorDefinitions" , typeof ( EditorDefinitionCollection ) , typeof ( PropertyGrid ) , new UIPropertyMetadata ( new EditorDefinitionCollection ( ) ) ) ;
public static readonly DependencyProperty EditorDefinitionsProperty = DependencyProperty . Register ( "EditorDefinitions" , typeof ( EditorDefinitionCollection ) , typeof ( PropertyGrid ) , new UIPropertyMetadata ( null ) ) ;
public EditorDefinitionCollection EditorDefinitions
public EditorDefinitionCollection EditorDefinitions
{
{
get { return ( EditorDefinitionCollection ) GetValue ( EditorDefinitionsProperty ) ; }
get { return ( EditorDefinitionCollection ) GetValue ( EditorDefinitionsProperty ) ; }
@ -124,6 +136,17 @@ namespace Microsoft.Windows.Controls.PropertyGrid
#endregion //Properties
#endregion //Properties
#region PropertyDefinitions
public static readonly DependencyProperty PropertyDefinitionsProperty = DependencyProperty . Register ( "PropertyDefinitions" , typeof ( PropertyDefinitionCollection ) , typeof ( PropertyGrid ) , new UIPropertyMetadata ( null ) ) ;
public PropertyDefinitionCollection PropertyDefinitions
{
get { return ( PropertyDefinitionCollection ) GetValue ( PropertyDefinitionsProperty ) ; }
set { SetValue ( PropertyDefinitionsProperty , value ) ; }
}
#endregion //PropertyDefinitions
#region SelectedObject
#region SelectedObject
public static readonly DependencyProperty SelectedObjectProperty = DependencyProperty . Register ( "SelectedObject" , typeof ( object ) , typeof ( PropertyGrid ) , new UIPropertyMetadata ( null , OnSelectedObjectChanged ) ) ;
public static readonly DependencyProperty SelectedObjectProperty = DependencyProperty . Register ( "SelectedObject" , typeof ( object ) , typeof ( PropertyGrid ) , new UIPropertyMetadata ( null , OnSelectedObjectChanged ) ) ;
@ -275,6 +298,8 @@ namespace Microsoft.Windows.Controls.PropertyGrid
public PropertyGrid ( )
public PropertyGrid ( )
{
{
EditorDefinitions = new EditorDefinitionCollection ( ) ;
PropertyDefinitions = new PropertyDefinitionCollection ( ) ;
CommandBindings . Add ( new CommandBinding ( PropertyGridCommands . ClearFilter , ClearFilter , CanClearFilter ) ) ;
CommandBindings . Add ( new CommandBinding ( PropertyGridCommands . ClearFilter , ClearFilter , CanClearFilter ) ) ;
}
}
@ -286,8 +311,11 @@ namespace Microsoft.Windows.Controls.PropertyGrid
{
{
base . OnApplyTemplate ( ) ;
base . OnApplyTemplate ( ) ;
_d ragThumb = ( Thumb ) GetTemplateChild ( "PART_DragThumb" ) ;
if ( _d ragThumb ! = null )
_d ragThumb . DragDelta + = DragThumb_DragDelta ;
_d ragThumb . DragDelta - = DragThumb_DragDelta ;
_d ragThumb = GetTemplateChild ( "PART_DragThumb" ) as Thumb ;
if ( _d ragThumb ! = null )
_d ragThumb . DragDelta + = DragThumb_DragDelta ;
}
}
protected override void OnPreviewKeyDown ( KeyEventArgs e )
protected override void OnPreviewKeyDown ( KeyEventArgs e )
@ -355,7 +383,26 @@ namespace Microsoft.Windows.Controls.PropertyGrid
try
try
{
{
var descriptors = PropertyGridUtilities . GetPropertyDescriptors ( instance ) ;
PropertyDescriptorCollection descriptors = PropertyGridUtilities . GetPropertyDescriptors ( instance ) ;
if ( ! AutoGenerateProperties )
{
List < PropertyDescriptor > specificProperties = new List < PropertyDescriptor > ( ) ;
foreach ( PropertyDefinition pd in PropertyDefinitions )
{
foreach ( PropertyDescriptor descriptor in descriptors )
{
if ( descriptor . Name = = pd . Name )
{
specificProperties . Add ( descriptor ) ;
break ;
}
}
}
descriptors = new PropertyDescriptorCollection ( specificProperties . ToArray ( ) ) ;
}
foreach ( PropertyDescriptor descriptor in descriptors )
foreach ( PropertyDescriptor descriptor in descriptors )
{
{
if ( descriptor . IsBrowsable )
if ( descriptor . IsBrowsable )