add PropertyGrid Demo

This commit is contained in:
NaBian committed 2020-06-15 22:47:04 +08:00
1 parent 0a9d95fafd
commit f7a39f3d32
18 files changed
+320 -82

No files matched your search

@@ -1,7 +1,23 @@
<UserControl x:Class="HandyControlDemo.UserControl.PropertyGridDemoCtl" <UserControl x:Class="HandyControlDemo.UserControl.PropertyGridDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:extension="clr-namespace:HandyControlDemo.Tools.Extension"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Background="{DynamicResource RegionBrush}"> Background="{DynamicResource RegionBrush}">
<userControl:UnderConstruction/> <hc:TransitioningContentControl>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<hc:PropertyGrid Width="500" SelectedObject="{Binding ElementName=ButtonDemo}"/>
<Border Margin="10" Background="{DynamicResource SecondaryRegionBrush}" Style="{StaticResource BorderRegion}" Grid.Column="1" Width="300">
<hc:SimplePanel>
<Button Name="ButtonDemo" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10" Width="200" Content="{extension:Lang Key={x:Static langs:LangKeys.Button}}"/>
</hc:SimplePanel>
</Border>
<hc:Divider Margin="0,20" Orientation="Vertical" LineStrokeDashArray="2,2" Grid.Column="0" HorizontalAlignment="Right"/>
</Grid>
</hc:TransitioningContentControl>
</UserControl> </UserControl>
@@ -0,0 +1,19 @@
using System.Windows;
namespace HandyControl.Controls
{
public class DatePropertyEditor : PropertyEditorBase
{
public override FrameworkElement CreateElement(PropertyItem propertyItem)
{
var picker = new DateTimePicker
{
IsEnabled = !propertyItem.IsReadOnly
};
picker.SetBinding(System.Windows.Controls.DatePicker.SelectedDateProperty, CreateBinding(propertyItem));
return picker;
}
}
}
@@ -2,9 +2,9 @@
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
public class IntegerPropertyEditor : PropertyEditorBase public class NumberPropertyEditor : PropertyEditorBase
{ {
public IntegerPropertyEditor(double minimum, double maximum) public NumberPropertyEditor(double minimum, double maximum)
{ {
Minimum = minimum; Minimum = minimum;
Maximum = maximum; Maximum = maximum;
@@ -0,0 +1,36 @@
using System.Windows;
namespace HandyControl.Controls
{
public class NumberPropertyEditor : PropertyEditorBase
{
public NumberPropertyEditor()
{
}
public NumberPropertyEditor(double minimum, double maximum)
{
Minimum = minimum;
Maximum = maximum;
}
public double Minimum { get; set; }
public double Maximum { get; set; }
public override FrameworkElement CreateElement(PropertyItem propertyItem)
{
var numericUpDown = new NumericUpDown
{
IsReadOnly = propertyItem.IsReadOnly,
Minimum = Minimum,
Maximum = Maximum
};
numericUpDown.SetBinding(NumericUpDown.ValueProperty, CreateBinding(propertyItem));
return numericUpDown;
}
}
}
@@ -0,0 +1,19 @@
using System.Windows;
namespace HandyControl.Controls
{
public class PlainTextPropertyEditor : PropertyEditorBase
{
public override FrameworkElement CreateElement(PropertyItem propertyItem)
{
var textbox = new System.Windows.Controls.TextBox
{
IsReadOnly = propertyItem.IsReadOnly
};
textbox.SetBinding(System.Windows.Controls.TextBox.TextProperty, CreateBinding(propertyItem));
return textbox;
}
}
}
@@ -11,8 +11,12 @@ namespace HandyControl.Controls
new Binding(propertyItem.PropertyName) new Binding(propertyItem.PropertyName)
{ {
Source = propertyItem.Value, Source = propertyItem.Value,
Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay, Mode = GetBindingMode(),
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged UpdateSourceTrigger = GetUpdateSourceTrigger()
}; };
public virtual BindingMode GetBindingMode() => BindingMode.OneWay;
public virtual UpdateSourceTrigger GetUpdateSourceTrigger() => UpdateSourceTrigger.Default;
} }
} }
@@ -2,7 +2,7 @@
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
public class StringPropertyEditor : PropertyEditorBase public class PlainTextPropertyEditor : PropertyEditorBase
{ {
public override FrameworkElement CreateElement(PropertyItem propertyItem) public override FrameworkElement CreateElement(PropertyItem propertyItem)
{ {
@@ -4,7 +4,7 @@ using HandyControl.Tools;
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
public class BooleanPropertyEditor : PropertyEditorBase public class SwitchPropertyEditor : PropertyEditorBase
{ {
public override FrameworkElement CreateElement(PropertyItem propertyItem) public override FrameworkElement CreateElement(PropertyItem propertyItem)
{ {
@@ -0,0 +1,19 @@
using System.Windows;
namespace HandyControl.Controls
{
public class TimePropertyEditor : PropertyEditorBase
{
public override FrameworkElement CreateElement(PropertyItem propertyItem)
{
var picker = new DateTimePicker
{
IsEnabled = !propertyItem.IsReadOnly
};
picker.SetBinding(TimePicker.SelectedTimeProperty, CreateBinding(propertyItem));
return picker;
}
}
}
@@ -1,20 +1,39 @@
using System.Collections.Generic; using System;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input;
using HandyControl.Data;
using HandyControl.Interactivity;
using HandyControl.Tools.Extension; using HandyControl.Tools.Extension;
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
[TemplatePart(Name = ElementItemsControl, Type = typeof(ItemsControl))] [TemplatePart(Name = ElementItemsControl, Type = typeof(ItemsControl))]
[TemplatePart(Name = ElementSearchBar, Type = typeof(SearchBar))]
public class PropertyGrid : Control public class PropertyGrid : Control
{ {
private const string ElementItemsControl = "PART_ItemsControl"; private const string ElementItemsControl = "PART_ItemsControl";
private const string ElementSearchBar = "PART_SearchBar";
private ItemsControl _itemsControl; private ItemsControl _itemsControl;
private ICollectionView _dataView;
private SearchBar _searchBar;
private string _searchKey;
public PropertyGrid()
{
CommandBindings.Add(new CommandBinding(ControlCommands.SortByCategory, SortByCategory));
CommandBindings.Add(new CommandBinding(ControlCommands.SortByName, SortByName));
}
public virtual PropertyResolver PropertyResolver { get; } = new PropertyResolver(); public virtual PropertyResolver PropertyResolver { get; } = new PropertyResolver();
public static readonly RoutedEvent SelectedObjectChangedEvent = public static readonly RoutedEvent SelectedObjectChangedEvent =
@@ -57,11 +76,41 @@ namespace HandyControl.Controls
set => SetValue(DescriptionProperty, value); set => SetValue(DescriptionProperty, value);
} }
public static readonly DependencyProperty MaxTitleWidthProperty = DependencyProperty.Register(
"MaxTitleWidth", typeof(double), typeof(PropertyGrid), new PropertyMetadata(default(double)));
public double MaxTitleWidth
{
get => (double) GetValue(MaxTitleWidthProperty);
set => SetValue(MaxTitleWidthProperty, value);
}
public static readonly DependencyProperty MinTitleWidthProperty = DependencyProperty.Register(
"MinTitleWidth", typeof(double), typeof(PropertyGrid), new PropertyMetadata(default(double)));
public double MinTitleWidth
{
get => (double) GetValue(MinTitleWidthProperty);
set => SetValue(MinTitleWidthProperty, value);
}
public override void OnApplyTemplate() public override void OnApplyTemplate()
{ {
if (_searchBar != null)
{
_searchBar.SearchStarted -= SearchBar_SearchStarted;
}
base.OnApplyTemplate(); base.OnApplyTemplate();
_itemsControl = GetTemplateChild(ElementItemsControl) as ItemsControl; _itemsControl = GetTemplateChild(ElementItemsControl) as ItemsControl;
_searchBar = GetTemplateChild(ElementSearchBar) as SearchBar;
if (_searchBar != null)
{
_searchBar.SearchStarted += SearchBar_SearchStarted;
}
UpdateItems(SelectedObject); UpdateItems(SelectedObject);
} }
@@ -69,35 +118,73 @@ namespace HandyControl.Controls
{ {
if (obj == null || _itemsControl == null) return; if (obj == null || _itemsControl == null) return;
var type = obj.GetType(); _dataView = CollectionViewSource.GetDefaultView(obj.GetType().GetProperties()
var propertyInfos = type.GetProperties(); .Where(item => PropertyResolver.ResolveBrowsable(item)).Select(CreatePropertyItem)
var itemList = propertyInfos.Select(CreatePropertyItem).Do(item => item.InitElement()).ToList(); .Do(item => item.InitElement()));
_itemsControl.ItemsSource = itemList;
var categorySet = new HashSet<string>(); SortByCategory(null, null);
foreach (var propertyItem in itemList) _itemsControl.ItemsSource = _dataView;
{
categorySet.Add(propertyItem.Category);
}
var view = CollectionViewSource.GetDefaultView(itemList);
view.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
} }
protected virtual PropertyItem CreatePropertyItem(PropertyInfo propertyInfo) => private void SortByCategory(object sender, ExecutedRoutedEventArgs e)
new PropertyItem {
using (_dataView.DeferRefresh())
{ {
Category = PropertyResolver.ResolveCategory(propertyInfo), _dataView.GroupDescriptions.Clear();
DisplayName = PropertyResolver.ResolveDisplayName(propertyInfo), _dataView.SortDescriptions.Clear();
Description = PropertyResolver.ResolveDescription(propertyInfo), _dataView.SortDescriptions.Add(new SortDescription(PropertyItem.CategoryProperty.Name, ListSortDirection.Ascending));
Browsable = PropertyResolver.ResolveBrowsable(propertyInfo), _dataView.SortDescriptions.Add(new SortDescription(PropertyItem.PropertyNameProperty.Name, ListSortDirection.Ascending));
IsReadOnly = PropertyResolver.ResolveIsReadOnly(propertyInfo), _dataView.GroupDescriptions.Add(new PropertyGroupDescription(PropertyItem.CategoryProperty.Name));
DefaultValue = PropertyResolver.ResolveDefaultValue(propertyInfo), }
Editor = PropertyResolver.ResolveEditor(propertyInfo), }
Converter = PropertyResolver.ResolveConverter(propertyInfo),
Value = SelectedObject, private void SortByName(object sender, ExecutedRoutedEventArgs e)
PropertyName = propertyInfo.Name, {
PropertyTypeName = propertyInfo.PropertyType.FullName using (_dataView.DeferRefresh())
}; {
_dataView.GroupDescriptions.Clear();
_dataView.SortDescriptions.Clear();
_dataView.SortDescriptions.Add(new SortDescription(PropertyItem.PropertyNameProperty.Name, ListSortDirection.Ascending));
}
}
private void SearchBar_SearchStarted(object sender, FunctionEventArgs<string> e)
{
_searchKey = e.Info;
if (string.IsNullOrEmpty(_searchKey))
{
foreach (UIElement item in _dataView)
{
item.Show();
}
}
else
{
foreach (PropertyItem item in _dataView)
{
item.Show(item.PropertyName.ToLower().Contains(_searchKey) || item.DisplayName.ToLower().Contains(_searchKey));
}
}
}
protected virtual PropertyItem CreatePropertyItem(PropertyInfo propertyInfo) => new PropertyItem
{
Category = PropertyResolver.ResolveCategory(propertyInfo),
DisplayName = PropertyResolver.ResolveDisplayName(propertyInfo),
Description = PropertyResolver.ResolveDescription(propertyInfo),
IsReadOnly = PropertyResolver.ResolveIsReadOnly(propertyInfo),
DefaultValue = PropertyResolver.ResolveDefaultValue(propertyInfo),
Editor = PropertyResolver.ResolveEditor(propertyInfo),
Converter = PropertyResolver.ResolveConverter(propertyInfo),
Value = SelectedObject,
PropertyName = propertyInfo.Name,
PropertyTypeName = propertyInfo.PropertyType.FullName
};
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
TitleElement.SetTitleWidth(this, new GridLength(Math.Max(MinTitleWidth, Math.Min(MaxTitleWidth, ActualWidth / 3))));
}
} }
} }
@@ -51,15 +51,6 @@ namespace HandyControl.Controls
set => SetValue(DescriptionProperty, value); set => SetValue(DescriptionProperty, value);
} }
public static readonly DependencyProperty BrowsableProperty = DependencyProperty.Register(
"Browsable", typeof(bool), typeof(PropertyItem), new PropertyMetadata(default(bool)));
public bool Browsable
{
get => (bool)GetValue(BrowsableProperty);
set => SetValue(BrowsableProperty, value);
}
public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register( public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register(
"IsReadOnly", typeof(bool), typeof(PropertyItem), new PropertyMetadata(default(bool))); "IsReadOnly", typeof(bool), typeof(PropertyItem), new PropertyMetadata(default(bool)));
@@ -25,7 +25,8 @@ namespace HandyControl.Controls
[typeof(ulong)] = EditorTypeCode.UInt64Number, [typeof(ulong)] = EditorTypeCode.UInt64Number,
[typeof(float)] = EditorTypeCode.SingleNumber, [typeof(float)] = EditorTypeCode.SingleNumber,
[typeof(double)] = EditorTypeCode.DoubleNumber, [typeof(double)] = EditorTypeCode.DoubleNumber,
[typeof(bool)] = EditorTypeCode.Switch [typeof(bool)] = EditorTypeCode.Switch,
[typeof(DateTime)] = EditorTypeCode.DateTime
}; };
public string ResolveCategory(PropertyInfo propertyInfo) public string ResolveCategory(PropertyInfo propertyInfo)
@@ -121,24 +122,24 @@ namespace HandyControl.Controls
TypeCodeDic.TryGetValue(type, out var editorType) TypeCodeDic.TryGetValue(type, out var editorType)
? (PropertyEditorBase) (editorType switch ? (PropertyEditorBase) (editorType switch
{ {
EditorTypeCode.PlainText => new StringPropertyEditor(), EditorTypeCode.PlainText => new PlainTextPropertyEditor(),
EditorTypeCode.SByteNumber => new IntegerPropertyEditor(sbyte.MinValue, sbyte.MaxValue), EditorTypeCode.SByteNumber => new NumberPropertyEditor(sbyte.MinValue, sbyte.MaxValue),
EditorTypeCode.ByteNumber => new IntegerPropertyEditor(byte.MinValue, byte.MaxValue), EditorTypeCode.ByteNumber => new NumberPropertyEditor(byte.MinValue, byte.MaxValue),
EditorTypeCode.Int16Number => new IntegerPropertyEditor(short.MinValue, short.MaxValue), EditorTypeCode.Int16Number => new NumberPropertyEditor(short.MinValue, short.MaxValue),
EditorTypeCode.UInt16Number => new IntegerPropertyEditor(ushort.MinValue, ushort.MaxValue), EditorTypeCode.UInt16Number => new NumberPropertyEditor(ushort.MinValue, ushort.MaxValue),
EditorTypeCode.Int32Number => new IntegerPropertyEditor(int.MinValue, int.MaxValue), EditorTypeCode.Int32Number => new NumberPropertyEditor(int.MinValue, int.MaxValue),
EditorTypeCode.UInt32Number => new IntegerPropertyEditor(uint.MinValue, uint.MaxValue), EditorTypeCode.UInt32Number => new NumberPropertyEditor(uint.MinValue, uint.MaxValue),
EditorTypeCode.Int64Number => new IntegerPropertyEditor(long.MinValue, long.MaxValue), EditorTypeCode.Int64Number => new NumberPropertyEditor(long.MinValue, long.MaxValue),
EditorTypeCode.UInt64Number => new IntegerPropertyEditor(ulong.MinValue, ulong.MaxValue), EditorTypeCode.UInt64Number => new NumberPropertyEditor(ulong.MinValue, ulong.MaxValue),
EditorTypeCode.SingleNumber => new IntegerPropertyEditor(float.MinValue, float.MaxValue), EditorTypeCode.SingleNumber => new NumberPropertyEditor(float.MinValue, float.MaxValue),
EditorTypeCode.DoubleNumber => new IntegerPropertyEditor(double.MinValue, double.MaxValue), EditorTypeCode.DoubleNumber => new NumberPropertyEditor(double.MinValue, double.MaxValue),
EditorTypeCode.Switch => new BooleanPropertyEditor(), EditorTypeCode.Switch => new SwitchPropertyEditor(),
EditorTypeCode.DateTime => new DateTimePropertyEditor(), EditorTypeCode.DateTime => new DateTimePropertyEditor(),
_ => new StringPropertyEditor() _ => new PlainTextPropertyEditor()
}) })
: new StringPropertyEditor(); : new PlainTextPropertyEditor();
public virtual PropertyEditorBase CreateEditor(Type type) => new StringPropertyEditor(); public virtual PropertyEditorBase CreateEditor(Type type) => new PlainTextPropertyEditor();
private enum EditorTypeCode private enum EditorTypeCode
{ {
@@ -40,11 +40,13 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Notification.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Notification.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Poptip.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Poptip.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Watermark.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Watermark.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\BooleanPropertyEditor.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\TimePropertyEditor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\DatePropertyEditor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\SwitchPropertyEditor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\DateTimePropertyEditor.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\DateTimePropertyEditor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\PropertyEditorBase.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\PropertyEditorBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\IntegerPropertyEditor.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\NumberPropertyEditor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\StringPropertyEditor.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\PlainTextPropertyEditor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\PropertyGrid.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\PropertyGrid.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\PropertyItem.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\PropertyItem.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\PropertyItemsControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\PropertyItemsControl.cs" />
@@ -429,6 +431,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="$(MSBuildThisFileDirectory)Themes\Styles\PropertyGrid.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Themes\Styles\Base\PropertyGridBaseStyle.xaml"> <Page Include="$(MSBuildThisFileDirectory)Themes\Styles\Base\PropertyGridBaseStyle.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -171,5 +171,15 @@ namespace HandyControl.Interactivity
/// 开始截图 /// 开始截图
/// </summary> /// </summary>
public static StartScreenshotCommand StartScreenshot { get; } = new StartScreenshotCommand(); public static StartScreenshotCommand StartScreenshot { get; } = new StartScreenshotCommand();
/// <summary>
/// 按照类别排序
/// </summary>
public static RoutedCommand SortByCategory { get; } = new RoutedCommand(nameof(SortByCategory), typeof(ControlCommands));
/// <summary>
/// 按照名称排序
/// </summary>
public static RoutedCommand SortByName { get; } = new RoutedCommand(nameof(SortByName), typeof(ControlCommands));
} }
} }
@@ -2,10 +2,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
xmlns:hc="clr-namespace:HandyControl.Controls" xmlns:hc="clr-namespace:HandyControl.Controls"
xmlns:themes="clr-namespace:HandyControl.Themes"> xmlns:themes="clr-namespace:HandyControl.Themes"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Basic/Effects.xaml"/>
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/GroupBox.xaml"/> <themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/GroupBox.xaml"/>
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/SearchBar.xaml"/>
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/ButtonGroup.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<DrawingBrush x:Key="SortByCategoryDrawingBrush" o:Freeze="True"> <DrawingBrush x:Key="SortByCategoryDrawingBrush" o:Freeze="True">
@@ -20,7 +24,7 @@
</DrawingBrush.Drawing> </DrawingBrush.Drawing>
</DrawingBrush> </DrawingBrush>
<DrawingBrush x:Key="SortAscendingDrawingBrush" o:Freeze="True"> <DrawingBrush x:Key="SortByNameDrawingBrush" o:Freeze="True">
<DrawingBrush.Drawing> <DrawingBrush.Drawing>
<DrawingGroup o:Freeze="True"> <DrawingGroup o:Freeze="True">
<GeometryDrawing o:Freeze="True" Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" /> <GeometryDrawing o:Freeze="True" Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" />
@@ -34,10 +38,11 @@
<Style x:Key="PropertyItemToolTipBaseStyle" BasedOn="{StaticResource {x:Type ToolTip}}" TargetType="ToolTip"> <Style x:Key="PropertyItemToolTipBaseStyle" BasedOn="{StaticResource {x:Type ToolTip}}" TargetType="ToolTip">
<Setter Property="Padding" Value="10"/> <Setter Property="Padding" Value="10"/>
<Setter Property="hc:BorderElement.CornerRadius" Value="2"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="ToolTip"> <ControlTemplate TargetType="ToolTip">
<Border Background="{DynamicResource RegionBrush}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{DynamicResource BorderBrush}"> <Border Effect="{StaticResource EffectShadow2}" Margin="8" Background="{DynamicResource RegionBrush}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{DynamicResource BorderBrush}">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
@@ -71,7 +76,7 @@
<ControlTemplate TargetType="hc:PropertyItem"> <ControlTemplate TargetType="hc:PropertyItem">
<GroupBox Style="{StaticResource GroupBoxOriginal}" hc:TitleElement.TitlePlacement="Left"> <GroupBox Style="{StaticResource GroupBoxOriginal}" hc:TitleElement.TitlePlacement="Left">
<GroupBox.Header> <GroupBox.Header>
<TextBlock Text="{TemplateBinding DisplayName}"> <TextBlock Padding="0,0,10,0" Width="{Binding Path=(hc:TitleElement.TitleWidth).Value,RelativeSource={RelativeSource TemplatedParent}}" Text="{TemplateBinding DisplayName}" TextTrimming="CharacterEllipsis">
<TextBlock.ToolTip> <TextBlock.ToolTip>
<ToolTip Style="{StaticResource PropertyItemToolTipBaseStyle}" Content="{TemplateBinding Description}"/> <ToolTip Style="{StaticResource PropertyItemToolTipBaseStyle}" Content="{TemplateBinding Description}"/>
</TextBlock.ToolTip> </TextBlock.ToolTip>
@@ -86,7 +91,7 @@
<Style x:Key="PropertyGroupItemBaseStyle" TargetType="GroupItem"> <Style x:Key="PropertyGroupItemBaseStyle" TargetType="GroupItem">
<Setter Property="Margin" Value="0,0,0,6"/> <Setter Property="Margin" Value="0,0,0,6"/>
<Setter Property="Padding" Value="10,10,6,4"/> <Setter Property="Padding" Value="10,6,6,0"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="GroupItem"> <ControlTemplate TargetType="GroupItem">
@@ -100,7 +105,19 @@
</Setter> </Setter>
</Style> </Style>
<ItemsPanelTemplate x:Key="PropertyItemsControlItemsPanelTemplate">
<VirtualizingStackPanel FocusVisualStyle="{x:Null}" VirtualizationMode="Recycling"/>
</ItemsPanelTemplate>
<Style x:Key="PropertyItemsControlBaseStyle" TargetType="hc:PropertyItemsControl">
<Setter Property="ItemContainerStyle" Value="{StaticResource PropertyItemBaseStyle}"/>
<Setter Property="ItemsPanel" Value="{StaticResource PropertyItemsControlItemsPanelTemplate}"/>
<Setter Property="Focusable" Value="False"/>
</Style>
<Style TargetType="hc:PropertyGrid"> <Style TargetType="hc:PropertyGrid">
<Setter Property="MaxTitleWidth" Value="200"/>
<Setter Property="MinTitleWidth" Value="120"/>
<Setter Property="Focusable" Value="False"/> <Setter Property="Focusable" Value="False"/>
<Setter Property="Padding" Value="10"/> <Setter Property="Padding" Value="10"/>
<Setter Property="Template"> <Setter Property="Template">
@@ -112,23 +129,19 @@
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<DockPanel LastChildFill="True"> <DockPanel LastChildFill="True" Margin="0,0,0,6">
<hc:ButtonGroup> <hc:ButtonGroup Style="{StaticResource ButtonGroupSolid}">
<RadioButton> <RadioButton Command="interactivity:ControlCommands.SortByCategory" IsChecked="True">
<Viewbox Width="16" Height="16"> <Rectangle Width="16" Height="16" Fill="{StaticResource SortByCategoryDrawingBrush}"/>
<Rectangle Width="16" Height="16" Fill="{StaticResource SortByCategoryDrawingBrush}"/>
</Viewbox>
</RadioButton> </RadioButton>
<RadioButton> <RadioButton Command="interactivity:ControlCommands.SortByName">
<Viewbox Width="16" Height="16"> <Rectangle Width="16" Height="16" Fill="{StaticResource SortByNameDrawingBrush}"/>
<Rectangle Width="16" Height="16" Fill="{StaticResource SortAscendingDrawingBrush}"/>
</Viewbox>
</RadioButton> </RadioButton>
</hc:ButtonGroup> </hc:ButtonGroup>
<hc:SearchBar Margin="6,0,0,6"/> <hc:SearchBar x:Name="PART_SearchBar" IsRealTime="True" Margin="6,0,0,0" ShowClearButton="True" Style="{StaticResource SearchBarPlus}"/>
</DockPanel> </DockPanel>
<ScrollViewer Grid.Row="1"> <ScrollViewer Grid.Row="1">
<hc:PropertyItemsControl x:Name="PART_ItemsControl" Focusable="False" ItemContainerStyle="{StaticResource PropertyItemBaseStyle}"> <hc:PropertyItemsControl x:Name="PART_ItemsControl" Style="{StaticResource PropertyItemsControlBaseStyle}">
<hc:PropertyItemsControl.GroupStyle> <hc:PropertyItemsControl.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource PropertyGroupItemBaseStyle}"/> <GroupStyle ContainerStyle="{StaticResource PropertyGroupItemBaseStyle}"/>
</hc:PropertyItemsControl.GroupStyle> </hc:PropertyItemsControl.GroupStyle>
@@ -1,6 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"> xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:themes="clr-namespace:HandyControl.Themes">
<ResourceDictionary.MergedDictionaries>
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Basic/Effects.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip"> <Style x:Key="ToolTipBaseStyle" TargetType="ToolTip">
<Setter Property="Padding" Value="0,6"/> <Setter Property="Padding" Value="0,6"/>
@@ -11,7 +16,7 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="ToolTip"> <ControlTemplate TargetType="ToolTip">
<Border Background="{DynamicResource RegionBrush}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{DynamicResource BorderBrush}"> <Border Effect="{StaticResource EffectShadow2}" Margin="8" Background="{DynamicResource RegionBrush}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{DynamicResource BorderBrush}">
<ContentPresenter Margin="10,0"/> <ContentPresenter Margin="10,0"/>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
@@ -0,0 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:themes="clr-namespace:HandyControl.Themes">
<ResourceDictionary.MergedDictionaries>
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Base/PropertyGridBaseStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource PropertyGridBaseStyle}" TargetType="controls:Badge"/>
</ResourceDictionary>
@@ -88,6 +88,7 @@
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/BlendEffectBox.xaml"/> <themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/BlendEffectBox.xaml"/>
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Screenshot.xaml"/> <themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Screenshot.xaml"/>
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Watermark.xaml"/> <themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Watermark.xaml"/>
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/PropertyGrid.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>