5 changed files with 75 additions and 110 deletions
|
After Width: | Height: | Size: 794 B |
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using System.Windows.Input; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Commands |
|||
{ |
|||
public class PropertyGridCommands |
|||
{ |
|||
private static RoutedCommand _clearFilterCommand = new RoutedCommand(); |
|||
public static RoutedCommand ClearFilter |
|||
{ |
|||
get |
|||
{ |
|||
return _clearFilterCommand; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,72 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Windows.Controls; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid |
|||
{ |
|||
public class PropertyCategoryItem : Control |
|||
{ |
|||
public static readonly DependencyProperty CategoryProperty = DependencyProperty.Register("Category", typeof(string), typeof(PropertyCategoryItem), new UIPropertyMetadata(String.Empty, new PropertyChangedCallback(OnCategoryChanged), new CoerceValueCallback(OnCoerceCategory))); |
|||
|
|||
private static object OnCoerceCategory(DependencyObject o, object value) |
|||
{ |
|||
PropertyCategoryItem propertyCategoryItem = o as PropertyCategoryItem; |
|||
if (propertyCategoryItem != null) |
|||
return propertyCategoryItem.OnCoerceCategory((string)value); |
|||
else |
|||
return value; |
|||
} |
|||
|
|||
private static void OnCategoryChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
PropertyCategoryItem propertyCategoryItem = o as PropertyCategoryItem; |
|||
if (propertyCategoryItem != null) |
|||
propertyCategoryItem.OnCategoryChanged((string)e.OldValue, (string)e.NewValue); |
|||
} |
|||
|
|||
protected virtual string OnCoerceCategory(string value) |
|||
{ |
|||
// TODO: Keep the proposed value within the desired range.
|
|||
return value; |
|||
} |
|||
|
|||
protected virtual void OnCategoryChanged(string oldValue, string newValue) |
|||
{ |
|||
// TODO: Add your property changed side-effects. Descendants can override as well.
|
|||
} |
|||
|
|||
public string Category |
|||
{ |
|||
// IMPORTANT: To maintain parity between setting a property in XAML and procedural code, do not touch the getter and setter inside this dependency property!
|
|||
get |
|||
{ |
|||
return (string)GetValue(CategoryProperty); |
|||
} |
|||
set |
|||
{ |
|||
SetValue(CategoryProperty, value); |
|||
} |
|||
} |
|||
|
|||
|
|||
private List<PropertyItem> _Properties = new List<PropertyItem>(); |
|||
public List<PropertyItem> Properties |
|||
{ |
|||
get |
|||
{ |
|||
return _Properties; |
|||
} |
|||
set |
|||
{ |
|||
_Properties = value; |
|||
} |
|||
} |
|||
|
|||
|
|||
static PropertyCategoryItem() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyCategoryItem), new FrameworkPropertyMetadata(typeof(PropertyCategoryItem))); |
|||
} |
|||
} |
|||
} |
|||
@ -1,24 +1,51 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Collections.ObjectModel; |
|||
using System.ComponentModel; |
|||
using System.Windows.Data; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid |
|||
{ |
|||
public class PropertyCollection : ObservableCollection<object> |
|||
public class PropertyCollection : ObservableCollection<PropertyItem> |
|||
{ |
|||
public PropertyCollection() |
|||
{ |
|||
|
|||
} |
|||
public PropertyCollection(List<object> list) |
|||
|
|||
public PropertyCollection(List<PropertyItem> list) |
|||
: base(list) |
|||
{ |
|||
|
|||
} |
|||
public PropertyCollection(IEnumerable<object> collection) |
|||
public PropertyCollection(IEnumerable<PropertyItem> collection) |
|||
: base(collection) |
|||
{ |
|||
|
|||
|
|||
} |
|||
|
|||
private ICollectionView GetDefaultView() |
|||
{ |
|||
return CollectionViewSource.GetDefaultView(this); |
|||
} |
|||
|
|||
public void GroupBy(string name) |
|||
{ |
|||
GetDefaultView().GroupDescriptions.Add(new PropertyGroupDescription(name)); |
|||
} |
|||
|
|||
public void SortBy(string name, ListSortDirection sortDirection) |
|||
{ |
|||
GetDefaultView().SortDescriptions.Add(new SortDescription(name, sortDirection)); |
|||
} |
|||
|
|||
public void Filter(string text) |
|||
{ |
|||
GetDefaultView().Filter = (item) => |
|||
{ |
|||
var property = item as PropertyItem; |
|||
return property.Name.ToLower().StartsWith(text.ToLower()); |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue