Skip to content

Instantly share code, notes, and snippets.

@Tide
Last active May 16, 2023 07:12
Show Gist options
  • Save Tide/2bf6d30297904a9a650c1e9cf800e07d to your computer and use it in GitHub Desktop.
Save Tide/2bf6d30297904a9a650c1e9cf800e07d to your computer and use it in GitHub Desktop.
PropertyGrid Style
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes;assembly=Xceed.Wpf.Toolkit"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<xctk:InverseBoolConverter x:Key="InverseBoolConverter" />
<xctk:HalfConverter x:Key="HalfConverter" />
<xctk:ExpandableObjectMarginConverter x:Key="ExpandableObjectMarginConverter" />
<xctk:ObjectToUIElementConverter x:Key="ObjectToUiElementConverter" />
<xctk:IsStringEmptyConverter x:Key="IsStringEmptyConverter" />
<xctk:IsDefaultCategoryConverter x:Key="IsDefaultCategoryConverter" />
<xctk:SelectedObjectConverter x:Key="ObjectConverter" />
<ContextMenu x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type xctk:PropertyGrid}, ResourceId=SelectedObjectAdvancedOptionsMenu}">
<MenuItem Command="xctk:PropertyItemCommands.ResetValue" Header="Reset Value" />
</ContextMenu>
<Style x:Key="OptionsToggleButtonStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Height" Value="22" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="ToolTipService.InitialShowDelay" Value="900" />
<Setter Property="ToolTipService.ShowDuration" Value="20000" />
<Setter Property="ToolTipService.BetweenShowDelay" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0" />
<Border x:Name="MiddleBorder"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0">
<Border x:Name="InnerBorder"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0"
Padding="{TemplateBinding Padding}">
<StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<ContentPresenter x:Name="Content"
Margin="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
RenderOptions.BitmapScalingMode="NearestNeighbor" />
</StackPanel>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonMouseOverBackgroundKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
<Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonMouseOverOuterBorderKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Content" Property="Opacity" Value="0.5" />
<Setter TargetName="OuterBorder" Property="TextElement.Foreground" Value="#FF9E9E9E" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonPressedBackgroundKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
<Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonPressedOuterBorderKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonPressedBackgroundKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
<Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonPressedOuterBorderKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ClearFilterButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Height" Value="22" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="ToolTipService.InitialShowDelay" Value="900" />
<Setter Property="ToolTipService.ShowDuration" Value="20000" />
<Setter Property="ToolTipService.BetweenShowDelay" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0" />
<Border x:Name="MiddleBorder"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0">
<Border x:Name="InnerBorder"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0"
Padding="{TemplateBinding Padding}">
<StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<ContentPresenter x:Name="Content"
Margin="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
RenderOptions.BitmapScalingMode="NearestNeighbor" />
</StackPanel>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonMouseOverBackgroundKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
<Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonMouseOverOuterBorderKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Content" Property="Opacity" Value="0.5" />
<Setter TargetName="OuterBorder" Property="TextElement.Foreground" Value="#FF9E9E9E" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonPressedBackgroundKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
<Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonPressedOuterBorderKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<SolidColorBrush x:Key="GlyphBrush" Color="Black" />
<ControlTemplate x:Key="ExpanderToggleButton" TargetType="{x:Type ToggleButton}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle x:Name="Rectangle"
Margin="0"
Fill="Transparent" />
<Path x:Name="Up_Arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M0,0L4,4 8,0z"
Fill="{StaticResource GlyphBrush}"
RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1" />
<SkewTransform AngleX="0" AngleY="0" />
<RotateTransform Angle="-90" />
<TranslateTransform X="0" Y="0" />
</TransformGroup>
</Path.RenderTransform>
</Path>
<Path x:Name="Down_Arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M0,4L4,0 8,4z"
Fill="{StaticResource GlyphBrush}"
RenderTransformOrigin="0.5,0.5"
Visibility="Collapsed">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1" />
<SkewTransform AngleX="0" AngleY="0" />
<RotateTransform Angle="135" />
<TranslateTransform X="0" Y="0" />
</TransformGroup>
</Path.RenderTransform>
</Path>
<ContentPresenter Grid.Column="1"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Down_Arrow" Property="Visibility" Value="Visible" />
<Setter TargetName="Up_Arrow" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Down_Arrow" Property="OpacityMask" Value="Black" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ExpanderStyle" TargetType="{x:Type Expander}">
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="#FFF0F0F0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition x:Name="ContentRow" Height="*" />
</Grid.RowDefinitions>
<Border x:Name="Border"
Background="{TemplateBinding Background}"
BorderBrush="#FFF0F0F0">
<ToggleButton IsChecked="{Binding Path=IsExpanded,
Mode=TwoWay,
RelativeSource={RelativeSource TemplatedParent}}"
OverridesDefaultStyle="True"
Template="{StaticResource ExpanderToggleButton}">
<ContentPresenter Margin="1"
ContentSource="Header"
RecognizesAccessKey="True"
TextElement.FontWeight="Bold" />
</ToggleButton>
</Border>
<Border x:Name="ExpandSite"
Grid.Row="1"
Background="#FFF0F0F0"
Padding="10,0,0,0"
Visibility="Collapsed">
<Border Margin="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderThickness="0"
Padding="0">
<ContentPresenter Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Focusable="False" />
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter TargetName="ExpandSite" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="PropertyExpanderStyle" TargetType="{x:Type Expander}">
<Setter Property="Padding" Value="10 0 0 0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<Grid>
<Border Visibility="Collapsed" Grid.Row="1" x:Name="ExpandSite" Padding="0 0 0 0">
<Border BorderThickness="0" Margin="0" Padding="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="false" />
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter Property="Visibility" Value="Visible" TargetName="ExpandSite" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="PropertyItemGroupContainerStyle" TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border>
<Expander x:Name="expander"
Header="{Binding Name}"
IsExpanded="True"
Style="{StaticResource ExpanderStyle}">
<ItemsPresenter />
</Expander>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Value="True">
<Condition.Binding>
<Binding Path="Name">
<Binding.Converter>
<xctk:IsDefaultCategoryConverter />
</Binding.Converter>
</Binding>
</Condition.Binding>
</Condition>
<Condition Binding="{Binding IsMiscCategoryLabelHidden, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type xctk:PropertyGrid}}}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<ItemsPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</MultiDataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type xctk:PropertyItem}"
BasedOn="{StaticResource {x:Type xctk:PropertyItemBase}}">
<Setter Property="Background"
Value="{x:Static SystemColors.WindowBrush}" />
<!-- Set the margin at 1 pixel bottom to let the horizontal "line" effect appear. -->
<Setter Property="Margin"
Value="0,0,0,1" />
<Setter Property="VerticalContentAlignment"
Value="Center" />
<Setter Property="SnapsToDevicePixels"
Value="True" />
<Setter Property="IsTabStop"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type xctk:PropertyItemBase}">
<Border ContextMenu="{Binding AdvancedOptionsMenu, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xctk:PropertyGrid}}"
ContextMenuService.Placement="Bottom">
<Grid VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding NameColumnWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type xctk:PropertyGrid}}}" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Set the BorderThickness at 1 pixel to the right to let the "vertical line" appear -->
<Border x:Name="PART_Name"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Margin="0,0,1,0"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Grid Margin="2,2,2,2"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid Margin="{Binding Level, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ExpandableObjectMarginConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ToggleButton x:Name="_expandableButton"
Grid.Column="0"
Template="{StaticResource ExpanderToggleButton}"
OverridesDefaultStyle="True"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
Visibility="{Binding IsExpandable, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />
<xctk:TrimmedTextBlock x:Name="_text"
Grid.Column="1"
Text="{Binding DisplayName, RelativeSource={RelativeSource TemplatedParent}}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
TextTrimming="CharacterEllipsis"
IsEnabled="{Binding IsReadOnly, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xctk:PropertyGrid}, Converter={StaticResource InverseBoolConverter}}"/>
</Grid>
<Grid Grid.Column="1"
HorizontalAlignment="Right"
Margin="5,0,5,0"
Visibility="{Binding ShowAdvancedOptions, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xctk:PropertyGrid}, Converter={StaticResource BooleanToVisibilityConverter}}"
xctk:ContextMenuUtilities.OpenOnMouseLeftButtonClick="True"
ContextMenu="{Binding AdvancedOptionsMenu, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xctk:PropertyGrid}}">
<Image x:Name="_optionsImage"
Width="11"
Height="11"
ToolTip="{Binding AdvancedOptionsTooltip, RelativeSource={RelativeSource TemplatedParent}}" />
</Grid>
</Grid>
</Border>
<Border x:Name="PART_Editor"
Grid.Column="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
KeyboardNavigation.DirectionalNavigation="None"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Border.ToolTip>
<ToolTip Visibility="Collapsed"/>
</Border.ToolTip>
<ContentControl x:Name="PART_ValueContainer" Margin="0,0,15,0"
Content="{TemplateBinding Editor}"
Focusable="False"
IsTabStop="False"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
IsEnabled="{Binding IsReadOnly, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xctk:PropertyGrid}, Converter={StaticResource InverseBoolConverter}}">
</ContentControl>
</Border>
<Expander x:Name="_propertyExpander"
Grid.ColumnSpan="2"
Grid.Row="1"
IsExpanded="{TemplateBinding IsExpanded}"
Style="{StaticResource PropertyExpanderStyle}"
IsEnabled="True">
<xctk:PropertyItemsControl x:Name="PART_PropertyItemsControl"
IsTabStop="False"
Focusable="False"
ItemsSource="{Binding Properties, RelativeSource={RelativeSource TemplatedParent}}"
ItemContainerStyle="{Binding PropertyContainerStyle, RelativeSource={RelativeSource TemplatedParent}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource PropertyItemGroupContainerStyle}"/>
</ItemsControl.GroupStyle>
</xctk:PropertyItemsControl>
</Expander>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter TargetName="PART_Name"
Property="Background"
Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonMouseOverBackgroundKey}}" />
</Trigger>
<Trigger Property="IsSelected"
Value="True">
<Setter TargetName="PART_Name"
Property="Background"
Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedBackgroundKey}}" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="Foreground"
TargetName="PART_ValueContainer"
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
<Setter Property="Foreground"
TargetName="_text"
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ShowDescriptionByTooltip, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xctk:PropertyGrid}}"
Value="True" />
<Condition Binding="{Binding Description, RelativeSource={RelativeSource Self}, Converter={StaticResource IsStringEmptyConverter}}"
Value="False" />
</MultiDataTrigger.Conditions>
<Setter Property="ToolTipService.ToolTip"
Value="{Binding Description, RelativeSource={RelativeSource TemplatedParent}}"
TargetName="PART_Name" />
</MultiDataTrigger>
<Trigger Property="Validation.HasError"
Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}" />
</Trigger>
<Trigger Property="Visibility"
Value="Visible"
SourceName="_expandableButton">
<Setter Property="Focusable"
Value="False" />
</Trigger>
<DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}"
Value="{x:Static xctk:StringConstants.Local}">
<Setter TargetName="_optionsImage"
Property="Source"
Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Local11.png" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}"
Value="{x:Static xctk:StringConstants.Resource}">
<Setter TargetName="_optionsImage"
Property="Source"
Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Resource11.png" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}"
Value="{x:Static xctk:StringConstants.Databinding}">
<Setter TargetName="_optionsImage"
Property="Source"
Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Database11.png" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}"
Value="{x:Static xctk:StringConstants.Inheritance}">
<Setter TargetName="_optionsImage"
Property="Source"
Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Inheritance11.png" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}"
Value="{x:Static xctk:StringConstants.StyleSetter}">
<Setter TargetName="_optionsImage"
Property="Source"
Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Style11.png" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}"
Value="{x:Static xctk:StringConstants.AdvancedProperties}">
<Setter TargetName="_optionsImage"
Property="Source"
Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/AdvancedProperties11.png" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type xctk:PropertyGrid}">
<Setter Property="Background" Value="{DynamicResource {ComponentResourceKey ResourceId=ButtonNormalBackgroundKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
<Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey ResourceId=ControlNormalBorderKey, TypeInTargetAssembly={x:Type themes:ResourceKeys}}}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="SelectedObjectType" Value="{Binding RelativeSource={RelativeSource Self}, Path=SelectedObject, Converter={StaticResource ObjectConverter}, ConverterParameter=Type}" />
<Setter Property="SelectedObjectTypeName" Value="{Binding RelativeSource={RelativeSource Self}, Path=SelectedObject, Converter={StaticResource ObjectConverter}, ConverterParameter=TypeName}" />
<Setter Property="SelectedObjectName" Value="{Binding RelativeSource={RelativeSource Self}, Path=SelectedObject, Converter={StaticResource ObjectConverter}, ConverterParameter=SelectedObjectName}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type xctk:PropertyGrid}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid Margin="{TemplateBinding Padding}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="5" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Border Width="44"
Height="44"
Margin="6,4,0,4"
Background="White"
BorderBrush="Black"
BorderThickness="1"
Padding="2"
Visibility="{Binding ShowPreview,
RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource BooleanToVisibilityConverter}}">
<Rectangle>
<Rectangle.Fill>
<VisualBrush Stretch="Uniform" Visual="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ObjectToUiElementConverter}, Path=SelectedObject}" />
</Rectangle.Fill>
</Rectangle>
</Border>
<StackPanel Margin="6,2,6,4"
VerticalAlignment="Center"
Orientation="Horizontal"
Visibility="{Binding ShowTitle,
RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid MaxWidth="{Binding ActualWidth, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource HalfConverter}, ConverterParameter=17}">
<xctk:TrimmedTextBlock FontWeight="Bold"
Text="{TemplateBinding SelectedObjectTypeName}"
TextTrimming="CharacterEllipsis" />
</Grid>
<Grid MaxWidth="{Binding ActualWidth, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource HalfConverter}, ConverterParameter=17}" Margin="5,0,0,0">
<xctk:TrimmedTextBlock Text="{TemplateBinding SelectedObjectName}" TextTrimming="CharacterEllipsis" />
</Grid>
</StackPanel>
</StackPanel>
<Grid x:Name="toolsContainer"
Grid.Row="1"
Margin="4,0,4,4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid x:Name="sortButtonContainer"
Margin="4"
Visibility="{Binding ShowSortOptions,
RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource BooleanToVisibilityConverter}}">
<StackPanel Margin="1" Orientation="Horizontal">
<RadioButton VerticalAlignment="Center"
IsChecked="{Binding IsCategorized,
RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource OptionsToggleButtonStyle}"
ToolTip="Categorized">
<Image Width="16"
Height="16"
Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Categorize16.png" />
</RadioButton>
<RadioButton VerticalAlignment="Center"
IsChecked="{Binding IsCategorized,
RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource InverseBoolConverter},
Mode=OneWay}"
Style="{StaticResource OptionsToggleButtonStyle}"
ToolTip="Alphabetical">
<Image Width="16"
Height="16"
Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/SortAscending16.png" />
</RadioButton>
</StackPanel>
</Grid>
<Border x:Name="searchBoxContainer"
Grid.Column="1"
Margin="4,4,6,4"
Background="White"
BorderBrush="Gray"
BorderThickness="1"
Visibility="{Binding ShowSearchBox,
RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<xctk:WatermarkTextBox x:Name="_txtFilter"
Background="Transparent"
Text="{Binding Filter,
RelativeSource={RelativeSource TemplatedParent},
UpdateSourceTrigger=PropertyChanged}"
Watermark="{TemplateBinding FilterWatermark}" />
<Button Grid.Column="1"
HorizontalAlignment="Left"
Command="xctk:PropertyGridCommands.ClearFilter"
Style="{StaticResource ClearFilterButtonStyle}">
<Image Width="16"
Height="16"
Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/ClearFilter16.png" />
</Button>
</Grid>
</Border>
</Grid>
<Grid Grid.Row="2" Background="{x:Static SystemColors.WindowBrush}">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<xctk:PropertyItemsControl x:Name="PART_PropertyItemsControl"
VerticalAlignment="Top"
Background="{x:Static SystemColors.ControlBrush}"
Focusable="False"
IsTabStop="False"
ItemsSource="{Binding Properties, RelativeSource={RelativeSource TemplatedParent}}"
ItemContainerStyle="{Binding PropertyContainerStyle,
RelativeSource={RelativeSource TemplatedParent}}">
<xctk:PropertyItemsControl.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource PropertyItemGroupContainerStyle}" />
</xctk:PropertyItemsControl.GroupStyle>
<xctk:PropertyItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Margin="0,0,10,0" />
</ItemsPanelTemplate>
</xctk:PropertyItemsControl.ItemsPanel>
</xctk:PropertyItemsControl>
</ScrollViewer>
<Thumb x:Name="PART_DragThumb"
Width="5"
Margin="6,0,0,0"
HorizontalAlignment="Left"
Cursor="SizeWE">
<Thumb.Template>
<ControlTemplate>
<Border Background="Transparent" />
</ControlTemplate>
</Thumb.Template>
</Thumb>
</Grid>
<GridSplitter Grid.Row="3"
Height="3"
HorizontalAlignment="Stretch"
Visibility="{Binding ShowSummary,
RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource BooleanToVisibilityConverter}}" />
<StackPanel Grid.Row="4"
Margin="0,0,0,5"
Visibility="{Binding ShowSummary,
RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource BooleanToVisibilityConverter}}">
<TextBlock FontWeight="Bold"
Padding="2,2,2,0"
Text="{Binding SelectedPropertyItem.DisplayName,
RelativeSource={RelativeSource TemplatedParent}}" />
<TextBlock Padding="5,2,2,0"
Text="{Binding SelectedPropertyItem.Description,
RelativeSource={RelativeSource TemplatedParent}}"
TextWrapping="WrapWithOverflow" />
</StackPanel>
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition SourceName="searchBoxContainer" Property="Visibility" Value="Collapsed" />
<Condition SourceName="sortButtonContainer" Property="Visibility" Value="Collapsed" />
</MultiTrigger.Conditions>
<Setter TargetName="toolsContainer" Property="Visibility" Value="Collapsed" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment