mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-12-02 11:57:37 +08:00
fixed #459
This commit is contained in:
parent
940117adc5
commit
64cd77ece0
@ -126,7 +126,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (obj == null || _itemsControl == null) return;
|
||||
|
||||
_dataView = CollectionViewSource.GetDefaultView(TypeDescriptor.GetProperties(obj).OfType<PropertyDescriptor>()
|
||||
_dataView = CollectionViewSource.GetDefaultView(TypeDescriptor.GetProperties(obj.GetType()).OfType<PropertyDescriptor>()
|
||||
.Where(item => PropertyResolver.ResolveIsBrowsable(item)).Select(CreatePropertyItem)
|
||||
.Do(item => item.InitElement()));
|
||||
|
||||
|
@ -6,7 +6,7 @@ using HandyControl.Data;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class PropertyItem : Control
|
||||
public class PropertyItem : ListBoxItem
|
||||
{
|
||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
|
||||
"Value", typeof(object), typeof(PropertyItem), new PropertyMetadata(default(object)));
|
||||
@ -107,15 +107,6 @@ namespace HandyControl.Controls
|
||||
set => SetValue(EditorElementProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
|
||||
"IsSelected", typeof(bool), typeof(PropertyItem), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get => (bool)GetValue(IsSelectedProperty);
|
||||
set => SetValue(IsSelectedProperty, ValueBoxes.BooleanBox(value));
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsExpandedEnabledProperty = DependencyProperty.Register(
|
||||
"IsExpandedEnabled", typeof(bool), typeof(PropertyItem), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
|
||||
|
@ -2,8 +2,16 @@
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class PropertyItemsControl : ItemsControl
|
||||
public class PropertyItemsControl : ListBox
|
||||
{
|
||||
protected override bool IsItemItsOwnContainerOverride(object item) => item is PropertyItem;
|
||||
|
||||
public PropertyItemsControl()
|
||||
{
|
||||
#if !NET40
|
||||
VirtualizingPanel.SetIsVirtualizingWhenGrouping(this, true);
|
||||
VirtualizingPanel.SetScrollUnit(this, ScrollUnit.Pixel);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@ -89,13 +89,32 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PropertyItemsControlBaseStyle" TargetType="hc:PropertyItemsControl">
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource PropertyItemBaseStyle}"/>
|
||||
<Setter Property="Focusable" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="hc:PropertyItemsControl">
|
||||
<hc:ScrollViewer Focusable="false" HorizontalScrollBarVisibility="Disabled">
|
||||
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</hc:ScrollViewer>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsGrouping" Value="False">
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PropertyGroupItemBaseStyle" TargetType="GroupItem">
|
||||
<Setter Property="Margin" Value="0,0,0,6"/>
|
||||
<Setter Property="Padding" Value="10,6,6,0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupItem">
|
||||
<Expander BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Header="{Binding Name}" IsExpanded="True" Background="{DynamicResource SecondaryRegionBrush}" Foreground="{DynamicResource PrimaryTextBrush}">
|
||||
<Expander Name="exp" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Header="{Binding Name}" IsExpanded="True" Background="{DynamicResource SecondaryRegionBrush}" Foreground="{DynamicResource PrimaryTextBrush}">
|
||||
<Border BorderThickness="1,0,1,1" BorderBrush="{DynamicResource BorderBrush}" Background="{DynamicResource RegionBrush}" CornerRadius="0,0,4,4">
|
||||
<ItemsPresenter Margin="{TemplateBinding Padding}"/>
|
||||
</Border>
|
||||
@ -105,16 +124,6 @@
|
||||
</Setter>
|
||||
</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 x:Key="PropertyGridBaseStyle" TargetType="hc:PropertyGrid">
|
||||
<Setter Property="MaxTitleWidth" Value="200"/>
|
||||
<Setter Property="MinTitleWidth" Value="120"/>
|
||||
@ -142,13 +151,11 @@
|
||||
</hc:ButtonGroup>
|
||||
<hc:SearchBar x:Name="PART_SearchBar" IsRealTime="True" ShowClearButton="True" Style="{StaticResource SearchBarPlus}"/>
|
||||
</DockPanel>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<hc:PropertyItemsControl x:Name="PART_ItemsControl" Style="{StaticResource PropertyItemsControlBaseStyle}">
|
||||
<hc:PropertyItemsControl Grid.Row="1" x:Name="PART_ItemsControl" Style="{StaticResource PropertyItemsControlBaseStyle}">
|
||||
<hc:PropertyItemsControl.GroupStyle>
|
||||
<GroupStyle ContainerStyle="{StaticResource PropertyGroupItemBaseStyle}"/>
|
||||
</hc:PropertyItemsControl.GroupStyle>
|
||||
</hc:PropertyItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
|
Loading…
Reference in New Issue
Block a user