WPF - 将文本绘制到 GridSplitter 上

发布于 2024-10-21 15:09:56 字数 329 浏览 4 评论 0原文

我声明这个网格分割器:

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

它是一个垂直网格分割器,我想使用 RotateTransform 绘制一些文本,以便文本从上到下运行。我无法让它发挥作用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手心的温暖 2024-10-28 15:09:57

这应该将文本呈现为旋转的。

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

然后,您需要将其包含在同一列中的 GridSplitter 之后。 IsHitTestVisible 是为了防止它干扰鼠标。

编辑:需要明确的是,这将是 Grid 的子级,而不是 GridSplitter。它只会在 GridSplitter 之上呈现。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文