Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: Custom Style Template for PropertyGrid not Working, Any Ideas?

$
0
0
I am using the toolkit v2.6 from NuGet in my project, but I don't know if there is something more I should be doing to allow me to theme or customize a control template.

After asking Designer/Blend to create a Copy of the Existing default Template for the PropertyGrid control, the UI is broken. The Template looks correct but no longer functions at Design-Time or Run-Time.

Before:
Image

After specifying a Style:
Image

Here is the Template Blend is Generating when specifying Edit Template > Edit a Copy...

```<Style x:Key="PropertyGridStyleDark" TargetType="{x:Type xctk:PropertyGrid}">
<Setter Property="AdvancedOptionsMenu">
            <Setter.Value>
                <ContextMenu>
                    <MenuItem Header="Reset Value">
                        <MenuItem.Command>
                            <RoutedCommand />
                        </MenuItem.Command>
                    </MenuItem>
                </ContextMenu>
            </Setter.Value>
        </Setter>
        <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">
            <Setter.Value>
                <Binding
                    ConverterParameter="Type"
                    Path="SelectedObject"
                    RelativeSource="{RelativeSource Self}">
                    <Binding.Converter>
                        <xctk:SelectedObjectConverter />
                    </Binding.Converter>
                </Binding>
            </Setter.Value>
        </Setter>
        <Setter Property="SelectedObjectTypeName">
            <Setter.Value>
                <Binding
                    ConverterParameter="TypeName"
                    Path="SelectedObject"
                    RelativeSource="{RelativeSource Self}">
                    <Binding.Converter>
                        <xctk:SelectedObjectConverter />
                    </Binding.Converter>
                </Binding>
            </Setter.Value>
        </Setter>
        <Setter Property="SelectedObjectName">
            <Setter.Value>
                <Binding
                    ConverterParameter="SelectedObjectName"
                    Path="SelectedObject"
                    RelativeSource="{RelativeSource Self}">
                    <Binding.Converter>
                        <xctk:SelectedObjectConverter />
                    </Binding.Converter>
                </Binding>
            </Setter.Value>
        </Setter>
        <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 x:Name="selectObjectNamePanel" Orientation="Horizontal">
                                <Border
                                    Width="44"
                                    Height="44"
                                    Margin="6,4,0,4"
                                    Padding="2"
                                    Background="White"
                                    BorderBrush="Black"
                                    BorderThickness="1">
                                    <Border.Visibility>
                                        <Binding Path="ShowPreview" RelativeSource="{RelativeSource TemplatedParent}">
                                            <Binding.Converter>
                                                <BooleanToVisibilityConverter />
                                            </Binding.Converter>
                                        </Binding>
                                    </Border.Visibility>
                                    <Rectangle>
                                        <Rectangle.Fill>
                                            <VisualBrush Stretch="Uniform">
                                                <VisualBrush.Visual>
                                                    <Binding Path="SelectedObject" RelativeSource="{RelativeSource TemplatedParent}">
                                                        <Binding.Converter>
                                                            <xctk:ObjectToUIElementConverter />
                                                        </Binding.Converter>
                                                    </Binding>
                                                </VisualBrush.Visual>
                                            </VisualBrush>
                                        </Rectangle.Fill>
                                    </Rectangle>
                                </Border>
                                <StackPanel
                                    Margin="6,2,6,4"
                                    VerticalAlignment="Center"
                                    Orientation="Horizontal">
                                    <StackPanel.Visibility>
                                        <Binding Path="ShowTitle" RelativeSource="{RelativeSource TemplatedParent}">
                                            <Binding.Converter>
                                                <BooleanToVisibilityConverter />
                                            </Binding.Converter>
                                        </Binding>
                                    </StackPanel.Visibility>
                                    <Grid>
                                        <Grid.MaxWidth>
                                            <Binding
                                                ConverterParameter="17"
                                                Path="ActualWidth"
                                                RelativeSource="{RelativeSource TemplatedParent}">
                                                <Binding.Converter>
                                                    <xctk:HalfConverter />
                                                </Binding.Converter>
                                            </Binding>
                                        </Grid.MaxWidth>
                                        <xctk:TrimmedTextBlock
                                            FontWeight="Bold"
                                            Text="{TemplateBinding SelectedObjectTypeName}"
                                            TextTrimming="CharacterEllipsis" />
                                    </Grid>
                                    <Grid Margin="5,0,0,0">
                                        <Grid.MaxWidth>
                                            <Binding
                                                ConverterParameter="17"
                                                Path="ActualWidth"
                                                RelativeSource="{RelativeSource TemplatedParent}">
                                                <Binding.Converter>
                                                    <xctk:HalfConverter />
                                                </Binding.Converter>
                                            </Binding>
                                        </Grid.MaxWidth>
                                        <xctk:TrimmedTextBlock Text="{TemplateBinding SelectedObjectName}" TextTrimming="CharacterEllipsis" />
                                    </Grid>
                                </StackPanel>
                            </StackPanel>
                            <ListView
                                x:Name="multiSelectObjectsNamePanel"
                                Background="Transparent"
                                Foreground="{TemplateBinding Foreground}"
                                BorderThickness="0"
                                Visibility="Collapsed">
                                <ListView.ItemTemplate>
.
.
.
``

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>