Browse Source

PropertyGrid: enabled the ability to define an EditorDefinition by property name as well. You can now have an EditorDefinition for a specific Type as well as for specific property names as well.

This example will provide a TextBox editor for any property of type DateTime as well as any property with the defined property names:

        <extToolkit:PropertyGrid>
            <extToolkit:PropertyGrid.EditorDefinitions>
                <extToolkit:EditorDefinition TargetType="{x:Type sys:DateTime}">
                    <extToolkit:EditorDefinition.Properties>                        
                        <sys:String>FirstName</sys:String>
                        <sys:String>LastName</sys:String>
                    </extToolkit:EditorDefinition.Properties>
                    <extToolkit:EditorDefinition.EditorTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding Value}" />
                        </DataTemplate>
                    </extToolkit:EditorDefinition.EditorTemplate>
                </extToolkit:EditorDefinition>
            </extToolkit:PropertyGrid.EditorDefinitions>
        </extToolkit:PropertyGrid>

You can also target just a Type or just property names.
pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
2d7ae5a473
  1. 1
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorPicker.cs
  2. 57
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml
  3. 4
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/EditorDefinition.cs
  4. 2
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/IEditorDefinition.cs

1
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorPicker.cs

@ -2,7 +2,6 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Controls.Primitives;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Microsoft.Windows.Controls.Core.Utilities;

57
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml

@ -54,7 +54,7 @@
</DrawingBrush.Drawing>
</DrawingBrush>
<Style x:Key="ColorPaletteLisBoxStyle" TargetType="{x:Type ListBoxItem}">
<Style x:Key="ColorItemContainerStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="ToolTip" Value="{Binding Name}" />
<Setter Property="Template">
<Setter.Value>
@ -143,6 +143,21 @@
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="ColorListStyle" TargetType="ListBox">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapPanel Width="200" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemContainerStyle" Value="{StaticResource ColorItemContainerStyle}" />
<Setter Property="ItemTemplate" Value="{StaticResource ColorItemTemplate}" />
<Setter Property="SelectionMode" Value="Single" />
</Style>
<Style TargetType="{x:Type local:ColorPicker}">
<Setter Property="Background" Value="White" />
@ -202,17 +217,9 @@
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="{TemplateBinding AvailableColorsHeader}" Background="AliceBlue" Padding="2" Margin="0,0,0,1" />
<ListBox x:Name="PART_AvailableColors" Grid.Row="1" Background="Transparent" BorderThickness="0" SelectionMode="Single"
ItemsSource="{Binding AvailableColors, RelativeSource={RelativeSource TemplatedParent}}"
ItemTemplate="{StaticResource ColorItemTemplate}"
ItemContainerStyle="{StaticResource ColorPaletteLisBoxStyle}"
Style="{x:Null}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="200" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
<ListBox x:Name="PART_AvailableColors" Grid.Row="1"
ItemsSource="{Binding AvailableColors, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ColorListStyle}" />
</Grid>
</Grid>
@ -224,17 +231,9 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{TemplateBinding StandardColorsHeader}" Background="AliceBlue" Padding="2" Margin="0,1,0,1"/>
<ListBox x:Name="PART_StandardColors" Grid.Row="1" SelectionMode="Single" Background="Transparent" BorderThickness="0"
<ListBox x:Name="PART_StandardColors" Grid.Row="1"
ItemsSource="{Binding StandardColors, RelativeSource={RelativeSource TemplatedParent}}"
ItemTemplate="{StaticResource ColorItemTemplate}"
ItemContainerStyle="{StaticResource ColorPaletteLisBoxStyle}"
Style="{x:Null}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="200" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
Style="{StaticResource ColorListStyle}" />
</Grid>
</Grid>
@ -246,17 +245,9 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{TemplateBinding RecentColorsHeader}" Background="AliceBlue" Padding="2" Margin="0,1,0,1"/>
<ListBox x:Name="PART_RecentColors" Grid.Row="1" SelectionMode="Single" Background="Transparent" BorderThickness="0"
ItemsSource="{Binding RecentColors, RelativeSource={RelativeSource TemplatedParent}}"
ItemTemplate="{StaticResource ColorItemTemplate}"
ItemContainerStyle="{StaticResource ColorPaletteLisBoxStyle}"
Style="{x:Null}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="200" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
<ListBox x:Name="PART_RecentColors" Grid.Row="1"
ItemsSource="{Binding RecentColors, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ColorListStyle}" />
</Grid>
</Grid>
</Grid>

4
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/EditorDefinition.cs

@ -8,8 +8,8 @@ namespace Microsoft.Windows.Controls.PropertyGrid
{
public DataTemplate EditorTemplate { get; set; }
private IList<string> _properties = new List<string>();
public IList<string> Properties
private List<string> _properties = new List<string>();
public List<string> Properties
{
get { return _properties; }
set { _properties = value; }

2
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/IEditorDefinition.cs

@ -7,7 +7,7 @@ namespace Microsoft.Windows.Controls.PropertyGrid
public interface IEditorDefinition
{
DataTemplate EditorTemplate { get; set; }
IList<string> Properties { get; set; }
List<string> Properties { get; set; }
Type TargetType { get; set; }
}
}

Loading…
Cancel
Save