This repository was archived by the owner on Oct 16, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
src/AddIns/DisplayBindings/WpfDesign
WpfDesign.Designer/Project
WpfDesign/Project/PropertyGrid Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -163,6 +163,8 @@ public static void Register()
163163 Metadata . AddPopularProperty ( typeof ( Binding ) , "ElementName" ) ;
164164 Metadata . AddPopularProperty ( typeof ( Binding ) , "Converter" ) ;
165165 Metadata . AddPopularProperty ( typeof ( Binding ) , "XPath" ) ;
166+
167+ Metadata . AddPopularProperty ( typeof ( ItemsControl ) , "Items" ) ;
166168
167169 Metadata . AddValueRange ( Block . LineHeightProperty , double . Epsilon , double . MaxValue ) ;
168170 Metadata . AddValueRange ( Canvas . BottomProperty , double . MinValue , double . MaxValue ) ;
@@ -219,7 +221,7 @@ public static void Register()
219221
220222 Metadata . HideProperty ( typeof ( UIElement ) , "RenderSize" ) ;
221223 Metadata . HideProperty ( FrameworkElement . NameProperty ) ;
222- Metadata . HideProperty ( typeof ( FrameworkElement ) , "Resources" ) ;
224+ // Metadata.HideProperty(typeof(FrameworkElement), "Resources");
223225 Metadata . HideProperty ( typeof ( Window ) , "Owner" ) ;
224226
225227 //Metadata.DisablePlacement(typeof(Button));
Original file line number Diff line number Diff line change 33 xmlns =" http://schemas.microsoft.com/netfx/2007/xaml/presentation"
44 xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
55 IsChecked =" {Binding Value}"
6+ Focusable =" False"
67 >
78</CheckBox >
Original file line number Diff line number Diff line change @@ -57,18 +57,28 @@ public FlatCollectionEditor()
5757 this . Owner = Application . Current . MainWindow ;
5858 }
5959
60+ public Type GetItemsSourceType ( Type t )
61+ {
62+ Type tp = t . GetInterfaces ( ) . FirstOrDefault ( x => x . IsGenericType && x . GetGenericTypeDefinition ( ) == typeof ( ICollection < > ) ) ;
63+
64+ return ( tp != null ) ? tp . GetGenericArguments ( ) [ 0 ] : null ;
65+ }
66+
6067 public void LoadItemsCollection ( DesignItemProperty itemProperty )
6168 {
6269 _itemProperty = itemProperty ;
6370 _componentService = _itemProperty . DesignItem . Services . Component ;
6471 TypeMappings . TryGetValue ( _itemProperty . ReturnType , out _type ) ;
72+
73+ _type = _type ?? GetItemsSourceType ( _itemProperty . ReturnType ) ;
74+
6575 if ( _type == null ) {
66- PropertyGridView . IsEnabled = false ;
67- ListBox . IsEnabled = false ;
76+ // PropertyGridView.IsEnabled=false;
77+ // ListBox.IsEnabled=false;
6878 AddItem . IsEnabled = false ;
69- RemoveItem . IsEnabled = false ;
70- MoveUpItem . IsEnabled = false ;
71- MoveDownItem . IsEnabled = false ;
79+ // RemoveItem.IsEnabled=false;
80+ // MoveUpItem.IsEnabled=false;
81+ // MoveDownItem.IsEnabled=false;
7282 }
7383
7484 ListBox . ItemsSource = _itemProperty . CollectionElements ;
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <UserControl
3+ x:Class=" ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.OpenCollectionEditor" xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml" >
4+ <Grid >
5+ <TextBlock
6+ Margin=" 0,0,20,0"
7+ Text=" {Binding Value}" VerticalAlignment =" Center" />
8+ <Button
9+ Width=" 15"
10+ Margin=" 0,0,1,0"
11+ HorizontalAlignment=" Right"
12+ VerticalAlignment=" Stretch"
13+ Content=" ..."
14+ Focusable=" False"
15+ Click=" open_Click" />
16+ </Grid >
17+ </UserControl >
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections ;
3+ using System . Collections . Generic ;
4+ using System . Linq ;
5+ using System . Text ;
6+ using System . Windows ;
7+ using System . Windows . Controls ;
8+ using System . Windows . Data ;
9+ using System . Windows . Documents ;
10+ using System . Windows . Input ;
11+ using System . Windows . Media ;
12+ using System . Windows . Media . Imaging ;
13+ using System . Windows . Navigation ;
14+ using System . Windows . Shapes ;
15+
16+ using ICSharpCode . WpfDesign . PropertyGrid ;
17+ //using Xceed.Wpf.Toolkit;
18+
19+ namespace ICSharpCode . WpfDesign . Designer . PropertyGrid . Editors
20+ {
21+ [ TypeEditor ( typeof ( ICollection ) ) ]
22+ public partial class OpenCollectionEditor : UserControl
23+ {
24+ public OpenCollectionEditor ( )
25+ {
26+ InitializeComponent ( ) ;
27+ }
28+
29+ void open_Click ( object sender , RoutedEventArgs e )
30+ {
31+ var node = this . DataContext as PropertyNode ;
32+
33+ var editor = new FlatCollectionEditor ( ) ;
34+ editor . LoadItemsCollection ( node . FirstProperty ) ;
35+ editor . ShowDialog ( ) ;
36+ }
37+ }
38+ }
Original file line number Diff line number Diff line change 9393 <DependentUpon >FlatCollectionEditor.xaml</DependentUpon >
9494 <SubType >Code</SubType >
9595 </Compile >
96+ <Compile Include =" PropertyGrid\Editors\OpenCollectionEditor.xaml.cs" >
97+ <DependentUpon >OpenCollectionEditor.xaml</DependentUpon >
98+ </Compile >
9699 <Compile Include =" Translations.cs" />
97100 <Compile Include =" Configuration\AssemblyInfo.cs" />
98101 <Compile Include =" Controls\AdornerLayer.cs" />
252255 <ItemGroup >
253256 <Page Include =" Extensions\RightClickContextMenu.xaml" />
254257 <Page Include =" PropertyGrid\Editors\FlatCollectionEditor.xaml" />
258+ <Page Include =" PropertyGrid\Editors\OpenCollectionEditor.xaml" />
255259 <Page Include =" ThumbnailView\ThumbnailView.xaml" />
256260 <ProjectReference Include =" ..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj" >
257261 <Project >{8035765F-D51F-4A0C-A746-2FD100E19419}</Project >
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ public static FrameworkElement CreateEditor(DesignItemProperty property)
5151 }
5252 type = type . BaseType ;
5353 }
54+
55+ foreach ( var t in typeEditors ) {
56+ if ( t . Key . IsAssignableFrom ( property . ReturnType ) ) {
57+ return ( FrameworkElement ) Activator . CreateInstance ( t . Value ) ;
58+ }
59+ }
60+
5461 if ( editorType == null ) {
5562 var standardValues = Metadata . GetStandardValues ( property . ReturnType ) ;
5663 if ( standardValues != null ) {
Original file line number Diff line number Diff line change 1717// DEALINGS IN THE SOFTWARE.
1818
1919using System ;
20+ using System . Collections ;
2021using System . Collections . Generic ;
2122using System . Linq ;
2223using System . Text ;
@@ -93,7 +94,7 @@ public static IEnumerable<PropertyDescriptor> GetAvailableProperties(object elem
9394 foreach ( PropertyDescriptor p in TypeDescriptor . GetProperties ( element ) )
9495 {
9596 if ( ! p . IsBrowsable ) continue ;
96- if ( p . IsReadOnly ) continue ;
97+ if ( p . IsReadOnly && ! typeof ( ICollection ) . IsAssignableFrom ( p . PropertyType ) ) continue ;
9798 if ( hiddenPropertiesOnWindow . Contains ( p . Name ) ) continue ;
9899 if ( p . Attributes . OfType < ObsoleteAttribute > ( ) . Count ( ) != 0 ) continue ;
99100 yield return p ;
@@ -103,7 +104,7 @@ public static IEnumerable<PropertyDescriptor> GetAvailableProperties(object elem
103104 {
104105 foreach ( PropertyDescriptor p in TypeDescriptor . GetProperties ( element ) ) {
105106 if ( ! p . IsBrowsable ) continue ;
106- if ( p . IsReadOnly ) continue ;
107+ if ( p . IsReadOnly && ! typeof ( ICollection ) . IsAssignableFrom ( p . PropertyType ) ) continue ;
107108 if ( p . Attributes . OfType < ObsoleteAttribute > ( ) . Count ( ) != 0 ) continue ;
108109 yield return p ;
109110 }
You can’t perform that action at this time.
0 commit comments