Content for Splitter

Docking/MDI for WPF Forum

Posted 15 years ago by sean hopen
Version: 4.5.0483
Avatar
How can I put a little graphic on the splitter so the user has a cue that it's there?

Comments (9)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Sean,

You could do this by making a Style that sets a new Template for docking:Splitter.


Actipro Software Support

Posted 15 years ago by sean hopen
Avatar
Thanks. that's what I was trying to do.

I usually edit a template by right-clicking in Blend and selecting "Edit Template"
Since the splitter doesn't actually appear in the layout (just SplitContainer), I don't know how to reference it.

Sorry if that's a silly WPF question, but some guidance here would be most welcome.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You'd just put something like this in your Application.Resources:
<Style x:Key="{x:Type docking:Splitter}" TargetType="{x:Type docking:Splitter}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type docking:Splitter}">
        ... template code here ...
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


Actipro Software Support

Posted 15 years ago by sean hopen
Avatar
Interesting. I guess by setting the key to the type it overrides for all objects of that type. I was looking for a place to set a style, but couldn't find any Splitter property.

I did try your suggestion:

<Style x:Key="{x:Type docking:Splitter}" TargetType="{x:Type docking:Splitter}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type docking:Splitter}">
                <Grid Width="Auto" Height="Auto" >
                    <Rectangle Width="25" Height="5" Fill="HotPink"></Rectangle>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
It compiles but I see no change in the splitter.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
My apologies... make two changes. Take out the x:Key and change the Style's TargetType to be docking:ContainerSplitter instead of docking:Splitter. That should work.


Actipro Software Support

Posted 15 years ago by sean hopen
Avatar
Compiler doesn't like the Property="Template"
It looks like SplitContainer doesn't have a public Template.
        
<Style TargetType="{x:Type docking:SplitContainer}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type docking:Splitter}">
                <Grid Width="Auto" Height="Auto" >
                    <Rectangle Width="25" Height="5" Fill="HotPink"></Rectangle>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Sean, it's docking:ContainerSplitter, not docking:SplitContainer.


Actipro Software Support

Posted 15 years ago by sean hopen
Avatar
Sorry, i thought you typo'd. That works.

        <Style TargetType="{x:Type docking:ContainerSplitter}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type docking:Splitter}">
                        <Grid Width="Auto" Height="Auto" >
                            <Rectangle Width="25" Height="5" Fill="HotPink"></Rectangle>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
Thanks!

[Modified at 01/09/2009 09:56 AM]
Posted 3 years ago by Neil Larson
Avatar

Here is an example for a 2 line hande on the splitter - 

         <Style TargetType="{x:Type docking:SplitContainerSplitter}">
            <Setter Property="Template">
               <Setter.Value>
                  <ControlTemplate TargetType="{x:Type docking:SplitContainerSplitter}">
                     <Border x:Name="SplitterBorder"
         					   BorderBrush="{TemplateBinding BorderBrush}"
         					   BorderThickness="{TemplateBinding BorderThickness}"
         					   Background="{TemplateBinding Background}"
         					   Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
                        <Border x:Name="HandleBorder" VerticalAlignment="Center"
         						   HorizontalAlignment="Center" BorderThickness="1 0"
         						   Background="White" BorderBrush="Black"/>
                     </Border>

                     <ControlTemplate.Triggers>
                        <Trigger Property="Orientation" Value="Horizontal">
                           <Setter TargetName="HandleBorder" Property="Width" Value="4" />
                           <Setter TargetName="HandleBorder" Property="Height" Value="50" />
                           <Setter TargetName="HandleBorder" Property="BorderThickness" Value="1 0" />
                        </Trigger>
                        <Trigger Property="Orientation" Value="Vertical">
                           <Setter TargetName="HandleBorder" Property="Height" Value="4" />
                           <Setter TargetName="HandleBorder" Property="Width" Value="50" />
                           <Setter TargetName="HandleBorder" Property="BorderThickness" Value="0 1" />
                        </Trigger>
                     </ControlTemplate.Triggers>

                  </ControlTemplate>
               </Setter.Value>
            </Setter>
         </Style>
The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.