add PropertyGrid v1
This commit is contained in:
1 parent
dea3287619
commit
0660a60e27
12 files changed
+90
-22
No files matched your search
@@ -39,8 +39,8 @@
|
||||
"title": "Controls",
|
||||
"selectedIndex": 0,
|
||||
"demoItemList": [
|
||||
[ "PropertyGrid", "PropertyGridDemoCtl", "PropertyGridEditorPart_16x", "1" ],
|
||||
[ "FloatingBlock", "FloatingBlockDemoCtl", "thumbs_up", "" ],
|
||||
[ "PropertyGrid", "PropertyGridDemoCtl", "PropertyGridEditorPart_16x", "1" ],
|
||||
[ "ImageBlock", "ImageBlockDemoCtl", "ImageStack_16x", "" ],
|
||||
[ "Magnifier", "MagnifierDemoCtl", "Search_16x", "" ],
|
||||
[ "Gravatar", "GravatarDemoCtl", "User_16x", "" ],
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace HandyControlDemo.Data
|
||||
{
|
||||
public class PropertyGridDemoModel
|
||||
{
|
||||
[Category("Info")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Category("Achievement")]
|
||||
public int Score { get; set; }
|
||||
|
||||
[Category("Achievement")]
|
||||
public bool IsPassed { get; set; }
|
||||
|
||||
[Category("Info")]
|
||||
public Gender Gender { get; set; }
|
||||
}
|
||||
|
||||
public enum Gender
|
||||
{
|
||||
Male,
|
||||
Female
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Model\CardModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Model\ChatInfoModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Model\AvatarModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Model\PropertyGridDemoModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Model\CoverViewDemoModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Model\DemoDataModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Model\DemoInfoModel.cs" />
|
||||
|
||||
@@ -2,20 +2,21 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}">
|
||||
<hc:TransitioningContentControl>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<hc:PropertyGrid Width="500" SelectedObject="{Binding ElementName=PathDemo}"/>
|
||||
<Border Margin="10" Background="{DynamicResource SecondaryRegionBrush}" Style="{StaticResource BorderRegion}" Grid.Column="1" Width="300">
|
||||
<hc:SimplePanel>
|
||||
<Path Name="PathDemo" Data="{StaticResource LogoGeometry}" Stretch="Fill" MaxWidth="256" MaxHeight="256" Width="200" Height="200" Fill="#f06632" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10"/>
|
||||
</hc:SimplePanel>
|
||||
</Border>
|
||||
<hc:Divider Margin="0,20" Orientation="Vertical" LineStrokeDashArray="2,2" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<Grid Margin="22">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<hc:PropertyGrid Width="500" SelectedObject="{Binding DemoModel}"/>
|
||||
<StackPanel Grid.Row="1" Margin="10,16,10,10">
|
||||
<TextBox hc:TitleElement.Title="Name" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.Name,Mode=OneWay}" IsReadOnly="True"/>
|
||||
<TextBox hc:TitleElement.Title="Gender" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.Gender,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
||||
<TextBox hc:TitleElement.Title="Score" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.Score,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
||||
<TextBox hc:TitleElement.Title="IsPassed" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.IsPassed,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</hc:TransitioningContentControl>
|
||||
</UserControl>
|
||||
+21
-1
@@ -1,10 +1,30 @@
|
||||
namespace HandyControlDemo.UserControl
|
||||
using System.Windows;
|
||||
using HandyControlDemo.Data;
|
||||
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class PropertyGridDemoCtl
|
||||
{
|
||||
public PropertyGridDemoCtl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DemoModel = new PropertyGridDemoModel
|
||||
{
|
||||
Name = "TestName",
|
||||
Gender = Gender.Female,
|
||||
IsPassed = true,
|
||||
Score = 98
|
||||
};
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DemoModelProperty = DependencyProperty.Register(
|
||||
"DemoModel", typeof(PropertyGridDemoModel), typeof(PropertyGridDemoCtl), new PropertyMetadata(default(PropertyGridDemoModel)));
|
||||
|
||||
public PropertyGridDemoModel DemoModel
|
||||
{
|
||||
get => (PropertyGridDemoModel) GetValue(DemoModelProperty);
|
||||
set => SetValue(DemoModelProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
-3
@@ -1,5 +1,4 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
@@ -11,7 +10,5 @@ namespace HandyControl.Controls
|
||||
};
|
||||
|
||||
public override DependencyProperty GetDependencyProperty() => System.Windows.Controls.TextBox.TextProperty;
|
||||
|
||||
public override BindingMode GetBindingMode(PropertyItem propertyItem) => BindingMode.OneWay;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace HandyControl.Controls
|
||||
Source = propertyItem.Value,
|
||||
Mode = GetBindingMode(propertyItem),
|
||||
UpdateSourceTrigger = GetUpdateSourceTrigger(propertyItem),
|
||||
Converter = GetConverter()
|
||||
Converter = GetConverter(propertyItem)
|
||||
});
|
||||
|
||||
public abstract DependencyProperty GetDependencyProperty();
|
||||
@@ -23,6 +23,6 @@ namespace HandyControl.Controls
|
||||
|
||||
public virtual UpdateSourceTrigger GetUpdateSourceTrigger(PropertyItem propertyItem) => UpdateSourceTrigger.PropertyChanged;
|
||||
|
||||
protected virtual IValueConverter GetConverter() => null;
|
||||
protected virtual IValueConverter GetConverter(PropertyItem propertyItem) => null;
|
||||
}
|
||||
}
|
||||
+3
@@ -1,5 +1,6 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using HandyControl.Tools;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
@@ -13,5 +14,7 @@ namespace HandyControl.Controls
|
||||
public override DependencyProperty GetDependencyProperty() => System.Windows.Controls.TextBox.TextProperty;
|
||||
|
||||
public override BindingMode GetBindingMode(PropertyItem propertyItem) => BindingMode.OneWay;
|
||||
|
||||
protected override IValueConverter GetConverter(PropertyItem propertyItem) => ResourceHelper.GetResource<IValueConverter>("Object2StringConverter");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
@@ -123,6 +124,8 @@ namespace HandyControl.Controls
|
||||
set => SetValue(IsExpandedEnabledProperty, value);
|
||||
}
|
||||
|
||||
public PropertyDescriptor PropertyDescriptor { get; set; }
|
||||
|
||||
public virtual void InitElement()
|
||||
{
|
||||
if (Editor == null) return;
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\Double2GridLengthConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\DoubleMinConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\Number2PercentageConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\Object2StringConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\RectangleCircularConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\ThicknessSplitConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\DependencyObjectExtension.cs" />
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<converter:ThicknessSplitConverter x:Key="ThicknessSplitConverter"/>
|
||||
<converter:CornerRadiusSplitConverter x:Key="CornerRadiusSplitConverter"/>
|
||||
<MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter"/>
|
||||
<converter:Double2GridLengthConverter x:Key="Double2GridLengthConverter" />
|
||||
<converter:DoubleMinConverter x:Key="DoubleMinConverter" />
|
||||
<converter:Double2GridLengthConverter x:Key="Double2GridLengthConverter"/>
|
||||
<converter:DoubleMinConverter x:Key="DoubleMinConverter"/>
|
||||
<converter:Object2StringConverter x:Key="Object2StringConverter"/>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Object2StringConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value?.ToString();
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user