WPF 刷新右侧文本 - 可能很容易吗?

发布于 2024-09-09 12:25:56 字数 455 浏览 4 评论 0原文

这对我们的设计师来说是一件好事。她的布局中,表单标题位于表单横幅的右上角,是两个英文单词。有多种形式,因此每次的单词都略有不同。所以效果是这样的:

|    firstword|
|         form|

在这个和左边的其他一些字段下面有一个奇特的俯冲东西。当然,对于几种不同的形式,单词的长度不同,所以有时单词在一行上,因为它们适合宽度:

|   short form|

她希望单词始终在两行上,基本上是经典的“右对齐”。据我所知,这实际上是不可能的,尤其是在本地化方面。如果您喜欢某些用换行符替换空格的代码隐藏,那么您的单词会消失或在本地化中不会使用所有空格。

所以我的问题是,在 WPF 中(也许在某些排版功能中)是否有一种方法可以轻松地获得右对齐外观 - 如果“form”一词始终位于底部并右对齐,与上面的任何其他单词对齐正确的。

This is a nice-to-have for our designer. She has a layout where a form title, on the top right of the form banner, is two words in English. There are several forms so the words are a little different each time. So the effect is something like:

|    firstword|
|         form|

There is a fancy swoopy thing underneath this and some other fields to the left. Of course with several different forms, the words are different lengths, so sometimes the words are on one line, because they fit in the width:

|   short form|

She wants the words to always be on two lines, basically classic 'flush right'. AFAIK this isn't really possible, especially with localization. If you get fancy with some codebehind that replaces the spaces with linebreaks, you'll have words that disappear or don't use all the space in localization.

So my question is if there is a way in WPF (maybe in some of those typography functions) to get a flush right look easily--if the word 'form' is always on the bottom and flush right, with whatever other words above flush right.

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

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

发布评论

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

评论(2

送你一个梦 2024-09-16 12:26:02

像这样的东西吗?

   <StackPanel Name="StackPanel1">
        <WrapPanel Name="WrapPanel1" HorizontalAlignment="Right">
            <TextBlock Name="TextBlock2"  HorizontalAlignment="Right" TextWrapping="Wrap">
                <TextBlock.Text>
                    Lorum Ipsum Dolum Lorum Ipsum Dolum Lorum Ipsum Dolum Lorum Ipsum Dolum Lorum Ipsum Dolum Lorum Ipsum Dolum 
                </TextBlock.Text>
            </TextBlock>
        </WrapPanel>
             <TextBlock Height="23" Name="TextBlock1" Text="Form" HorizontalAlignment="Right" />
   </StackPanel>

Something like this?

   <StackPanel Name="StackPanel1">
        <WrapPanel Name="WrapPanel1" HorizontalAlignment="Right">
            <TextBlock Name="TextBlock2"  HorizontalAlignment="Right" TextWrapping="Wrap">
                <TextBlock.Text>
                    Lorum Ipsum Dolum Lorum Ipsum Dolum Lorum Ipsum Dolum Lorum Ipsum Dolum Lorum Ipsum Dolum Lorum Ipsum Dolum 
                </TextBlock.Text>
            </TextBlock>
        </WrapPanel>
             <TextBlock Height="23" Name="TextBlock1" Text="Form" HorizontalAlignment="Right" />
   </StackPanel>
从﹋此江山别 2024-09-16 12:26:01

听起来组成这两条线的数据是提前分开的。因此,最好将其分开,而不是将其组合起来以便稍后解析。我认为正是这让你走到了现在的位置。

如果数据保持独立,那么您无需担心尾随空格(或者很容易修剪)。将其放到显示器上时,只需将换行符插入其中即可。

Sounds like the data that make up the 2 lines is separate ahead of time. As such it would be best to keep it separate rather than have it combined only to have to parse out later. Which I think is what led you to where you are now.

If the data is kept separate then you don't need to worry about trailing spaces (or it is easily trimmed). Simply stick a line feed in there when putting it to the display.

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