Search code examples
wpfgridsplitter

WPF - drawing text onto a GridSplitter


I am declaring this Grid Splitter:

<GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Grid.Column="1" Grid.RowSpan="1" Grid.Row="1" Width="5" Background="#FFBCBCBC" ResizeBehavior="PreviousAndNext">
    </GridSplitter>

It is a vertical grid splitter and I want to draw some text using RotateTransform so the text runs from top to bottom. I am having trouble getting it to work.


Solution

  • This should render the text as rotated.

    <TextBlock Text="Testing" HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False">
        <TextBlock.LayoutTransform>
            <RotateTransform Angle="90" />
        </TextBlock.LayoutTransform>
    </TextBlock>
    

    You would then need to include it after your GridSplitter in the same column. The IsHitTestVisible is just in case it interferes with the mouse.

    EDIT: Just to be clear, this would be a child of the Grid, not the GridSplitter. It would simply render on top of the GridSplitter.