我使用的是star转换器具有相对大的ListView列,但我现在的问题是,这并没有考虑到,如果滚动条是可见或不可见。我尝试添加类似下面的进入code:
I am using a star converter to have relative sized listview columns, but my current problem is that this does not take into account if the scrollbar is visible or not. I tried to add something like the following into the code:
var scroll = FindVisualChild<ScrollViewer>(listView);
var offset = 0.0;
if (scroll.ComputedVerticalScrollBarVisibility == Visibility.Visible)
offset = SystemParameters.ScrollWidth + 5;
不过,上浆的滚动条可见性之前完成,并滚动总是被显示为折叠
。
所以,我的问题是,我怎么能适当地调整我的专栏。我尝试添加对 ScrollViewer.ComputedVerticalScrollBarVisibility
触发,但还没有出现任何的成功。我试图用定制$ C $根据关此链接,但最后总是一个空白列表视图当前(可能是由于使用的项目presenter列表视图,但我不知道目前)。
So, my question is, how can I resize my columns appropriately. I have tried to add a trigger on ScrollViewer.ComputedVerticalScrollBarVisibility
, but have not had any success there. I tried to use custom code based off of this link, but always end up with a blank listview currently (may be due to the listview using an ItemsPresenter, but I am not sure currently).
下面是我尝试过的列表视图设置:
Here is the listview setup that I have tried:
<Style x:Key="{x:Type ListView}" TargetType="ListView">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListView">
<Border Name="Border" BorderThickness="0" BorderBrush="#999999" >
<ScrollViewer x:Name="blah" >
<ItemsPresenter />
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger SourceName="blah" Property="ComputedVerticalScrollBarVisibility" Value="Hidden">
<Setter Property="BorderBrush" Value="Aqua"/>
<Setter Property="BorderThickness" Value="10"/>
</Trigger>
<Trigger SourceName="blah" Property="ComputedVerticalScrollBarVisibility" Value="Collapsed">
<Setter Property="BorderBrush" Value="Orange"/>
<Setter Property="BorderThickness" Value="10"/>
</Trigger>
<Trigger SourceName="blah" Property="ComputedVerticalScrollBarVisibility" Value="Visible">
<Setter Property="BorderBrush" Value="Red"/>
<Setter Property="BorderThickness" Value="10"/>
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="Border" Property="Background" Value="#BBBBBB"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
的制定者只是来看看它是否工作...但他们永远不会置在所有
The setters are just to see if it works...but they are never set at all
我结束了创建一种黑客攻击。 这是我最初的博客文章上它,因为它可以得到相当长。我还需要清理code,但希望它可以帮助别人
I ended up creating a kind of hack. Here is my initial blog post on it as it can get quite long. I still need to clean up the code, but hopefully it helps others