6 changed files with 159 additions and 2 deletions
@ -0,0 +1,14 @@ |
|||
<UserControl x:Class="Microsoft.Windows.Controls.PropertyGrid.Editors.CollectionEditor" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition Width="Auto" /> |
|||
</Grid.ColumnDefinitions> |
|||
<TextBlock Text="(Collection)" VerticalAlignment="Center" /> |
|||
<Button Grid.Column="1" |
|||
Content=" ... " |
|||
Click="Button_Click"/> |
|||
</Grid> |
|||
</UserControl> |
|||
@ -0,0 +1,45 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Data; |
|||
using System.Windows.Documents; |
|||
using System.Windows.Input; |
|||
using System.Windows.Media; |
|||
using System.Windows.Media.Imaging; |
|||
using System.Windows.Navigation; |
|||
using System.Windows.Shapes; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Editors |
|||
{ |
|||
/// <summary>
|
|||
/// Interaction logic for CollectionEditor.xaml
|
|||
/// </summary>
|
|||
public partial class CollectionEditor : UserControl, ITypeEditor |
|||
{ |
|||
PropertyItem _item; |
|||
|
|||
public CollectionEditor() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
public void Attach(PropertyItem propertyItem) |
|||
{ |
|||
_item = propertyItem; |
|||
} |
|||
|
|||
public FrameworkElement ResolveEditor() |
|||
{ |
|||
return this; |
|||
} |
|||
|
|||
private void Button_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
CollectionEditorDialog editor = new CollectionEditorDialog(_item); |
|||
editor.ShowDialog(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
<Window x:Class="Microsoft.Windows.Controls.PropertyGrid.Editors.CollectionEditorDialog" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:propertyGrid="clr-namespace:Microsoft.Windows.Controls.PropertyGrid" |
|||
Title="Collection Editor" Height="400" Width="800" WindowStartupLocation="CenterScreen"> |
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="*" /> |
|||
<RowDefinition Height="Auto" /> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition Width="*"/> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<ListBox x:Name="_listBox" /> |
|||
|
|||
<propertyGrid:PropertyGrid x:Name="_propertyGrid" Grid.Column="1" SelectedObject="{Binding SelectedItem, ElementName=_listBox}" /> |
|||
</Grid> |
|||
|
|||
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right" Margin="5" > |
|||
<Button Width="65" Margin="2" Click="Button_Click" >OK</Button> |
|||
<!--<Button Width="65" Margin="2">Cancel</Button>--> |
|||
</StackPanel> |
|||
|
|||
</Grid> |
|||
</Window> |
|||
@ -0,0 +1,48 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Data; |
|||
using System.Windows.Documents; |
|||
using System.Windows.Input; |
|||
using System.Windows.Media; |
|||
using System.Windows.Media.Imaging; |
|||
using System.Windows.Shapes; |
|||
using System.Collections; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Editors |
|||
{ |
|||
/// <summary>
|
|||
/// Interaction logic for CollectionEditorDialog.xaml
|
|||
/// </summary>
|
|||
public partial class CollectionEditorDialog : Window |
|||
{ |
|||
PropertyItem _item; |
|||
|
|||
public CollectionEditorDialog() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
public CollectionEditorDialog(PropertyItem item) |
|||
: this() |
|||
{ |
|||
_item = item; |
|||
_listBox.ItemsSource = _item.Value as IEnumerable; |
|||
} |
|||
|
|||
//public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(object), typeof(CollectionEditorDialog), new UIPropertyMetadata(null));
|
|||
//public object ItemsSource
|
|||
//{
|
|||
// get { return (object)GetValue(ItemsSourceProperty); }
|
|||
// set { SetValue(ItemsSourceProperty, value); }
|
|||
//}
|
|||
|
|||
private void Button_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
Close(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue