【问题标题】:wpf listview itempanel scrollviewerwpf listview itempanel 滚动查看器
【发布时间】:2017-02-26 09:22:26
【问题描述】:

当我在WrapPanel 中设置ListView.ItemsPanel 时,右滚动条会丢失(不可见)。并且内容是通过鼠标滚轮滚动的,当然,通过研究此滚动查看器中的可视化树,所有属性都已正确安装。这里可能有什么问题以及为什么他不可见。

        <Style TargetType="{x:Type ListView}">
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <WrapPanel Background="Transparent" MouseDown="WrapPanel_MouseDown_1" 
                             IsItemsHost="True"
                             Width="{Binding Path=ActualWidth,  RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ScrollContentPresenter}}}">

                        </WrapPanel>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Path Fill="{Binding ElementName=tBlock, Path=Foreground}" Width="20" Height="20" Margin="5, 0, 0, 0" Stretch="Uniform" Data="{Binding SmallIcon}" />
                            <TextBlock Margin="5, 4, 5, 0" x:Name="tBlock" Grid.Column="1" TextWrapping="Wrap" Width="200" Text="{Binding Name}"></TextBlock>
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

这是截图:

【问题讨论】:

    标签: wpf listview scrollviewer itemspaneltemplate itemspanel


    【解决方案1】:

    VerticalScrollBarVisibility 和/或HorizontalScrollBarVisibility 设置为所需的值:

    <ListView
              ScrollViewer.HorizontalScrollBarVisibility="Visible" 
              ScrollViewer.VerticalScrollBarVisibility="Visible"> 
        <ListView.Style>
            <Style TargetType="{x:Type ListView}">
             // ...
    

    VerticalScrollBarVisibility 默认为Auto,我无法复制您的问题。不过,我希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-21
      • 2011-02-18
      • 2011-08-05
      相关资源
      最近更新 更多