如何获得或计算列表框的实际宽度没有垂直滚动条,如果可见 [英] How to get or compute actual width of ListBox without Vertical Scrollbar if visible

查看:216
本文介绍了如何获得或计算列表框的实际宽度没有垂直滚动条,如果可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何获得或计算的实际宽度的的ListBox 的没有的垂直滚动条的,如果是可见的。

I wonder how to get or compute actual width of ListBox without Vertical Scrollbar if visible.

我想要做的就是改变每个项目的宽度内的的ListBox 的没有被覆盖的垂直滚动条

What I want to do is changing width of each items inside ListBox without being covered by Vertical Scrollbar.

Width="{Binding ActualWidth, 
    RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}}

至少,结合以上告诉我的的ListBox 的实际宽度,但是这一次不处理垂直滚动条的宽度。

At least, above binding tell me the actual width of ListBox, but this one does not handle width of vertical scrollbar.

有没有办法解决这个问题的好办法?

Is there any good way to solve this?

推荐答案

尝试结合的 ViewportWidth 属性包含的ScrollViewer 来代替。

Try binding to the ViewportWidth property of the containing ScrollViewer instead.

这样的:

Width="{Binding Path=ViewportWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ScrollViewer}}"

这篇关于如何获得或计算列表框的实际宽度没有垂直滚动条,如果可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆