feature : Collection Editor -> better display of some types

This commit is contained in:
jkuehner 2018-07-01 17:44:38 +02:00
Родитель 21361142f7
Коммит c0ffbd3591
4 изменённых файлов: 70 добавлений и 9 удалений

Просмотреть файл

@ -0,0 +1,20 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wpfDesign="clr-namespace:ICSharpCode.WpfDesign;assembly=ICSharpCode.WpfDesign">
<DataTemplate x:Key="PointTemplate" DataType="wpfDesign:DesignItem">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Point (" />
<TextBlock Text="{Binding Component.X}" />
<TextBlock Text=" / " />
<TextBlock Text="{Binding Component.Y}" />
<TextBlock Text=")" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="StringTemplate" DataType="wpfDesign:DesignItem">
<TextBlock Text="{Binding Component}" />
</DataTemplate>
<DataTemplate x:Key="DefaultTemplate" DataType="wpfDesign:DesignItem">
<TextBlock Text="{Binding ComponentType.Name}" />
</DataTemplate>
</ResourceDictionary>

Просмотреть файл

@ -0,0 +1,29 @@
using System;
using System.Windows;
using System.Windows.Controls;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
public class CollectionTemplateSelector : DataTemplateSelector
{
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
FrameworkElement element = container as FrameworkElement;
if (element != null && item != null && item is DesignItem)
{
var di = item as DesignItem;
if (di.Component is Point)
{
return element.FindResource("PointTemplate") as DataTemplate;
}
else if (di.Component is String)
{
return element.FindResource("StringTemplate") as DataTemplate;
}
return element.FindResource("DefaultTemplate") as DataTemplate;
}
return null;
}
}
}

Просмотреть файл

@ -1,10 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FlatCollectionEditor" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:OutlineView="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView" xmlns:PropertyGrid="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid"
x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FlatCollectionEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:PropertyGrid="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid"
Height="438"
Width="750"
Title="Edit Items"
WindowStartupLocation="CenterScreen" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
WindowStartupLocation="CenterScreen"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:editors="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
@ -20,15 +26,17 @@
BorderThickness="0.75"
Margin="10"
SnapsToDevicePixels="True">
<Border.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="CollectionTemplateDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
<editors:CollectionTemplateSelector x:Key="CollectionTemplateSelector" />
</ResourceDictionary>
</Border.Resources>
<ListBox
x:Name="ListBox"
SelectionChanged="ListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding ComponentType.Name}" />
</DataTemplate>
</ListBox.ItemTemplate>
SelectionChanged="ListBox_SelectionChanged" ItemTemplateSelector="{StaticResource CollectionTemplateSelector}">
</ListBox>
</Border>
<Button

Просмотреть файл

@ -87,6 +87,10 @@
<Compile Include="Extensions\BorderForMouseOver.cs" />
<Compile Include="Extensions\OnlyDeletePlacementBehavior.cs" />
<Compile Include="OutlineView\PropertyOutlineNode.cs" />
<Page Include="PropertyGrid\Editors\CollectionTemplateDictionary.xaml">
<SubType>Designer</SubType>
</Page>
<Compile Include="PropertyGrid\Editors\CollectionTemplateSelector.cs" />
<Compile Include="PropertyGrid\Editors\ColorEditor\ColorEditorPopup.xaml.cs">
<DependentUpon>ColorEditorPopup.xaml</DependentUpon>
</Compile>