重新缩放列表框或其他项目?但不是文本 (WPF)
这个问题很清楚。我的视图中有列表视图或列表框。 如果我缩小屏幕,我希望我的文本(标签等)保持相同的大小。但是列表视图和列表框必须变得更小,最终带有滚动条?
我该怎么做?
谢谢
The question is quite clear. I have listviews or listboxes in my view.
If i make my screen smaller, i want that my text (labels etc) stay the same size. But the listviews and listboxes have to become smaller, eventually with a scrollbar?
how do i do this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ListBox 内置了一个 ScrollViewer。
the ListBox has a ScrollViewer built in.
嗯,不完全是。但我认为这就是您正在寻找的。首先,创建一个接受
Double
并返回其倒数的值转换器:现在您可以使用
ScaleTransform
缩放任何内容控件,并使用ReciprocalValueConverter
code> 将其中包含的任何单个元素保持为原始比例。因此,如果内容控件的比例加倍,则要保持不变的内容的比例将减半。此示例显示了缩放内容控件和通过将
LayoutTransform
分配给每个项目来“取消缩放”列表框中的项目:Well, not exactly. But I think this is what you're looking for. First, create a value converter that takes a
Double
and returns its reciprocal:Now you can scale any content control, using a
ScaleTransform
, and use theReciprocalValueConverter
to keep any individual element contained within it to the original scale. So if the content control's scale is doubled, the content that you want to remain unchanged has its scale halved.This example shows both scaling content controls and "unscaling" the items in a list box by assigning the
LayoutTransform
to each item: