Windows 8 ScrollViewer打破了TextBlock Wrap

时间:2014-04-10 14:29:39

标签: wpf xaml listview scrollview windows-8.1

我有一个ListView,它包含一个带有几个文本框的网格,并且列的宽度绑定到页面的ActualWidth属性。

问题是垂直滚动条放在列表中最大的项目之后(不会卡在页面的右侧)。如果我在ListView之前添加ScrollViewer,则垂直滚动条位于我想要的位置(捕捉到页面的右侧),但是文本不再包含(跨越多行以适合屏幕上的所有文本)但它继续走出窗外的界限。

这是包含文本的xaml:

<Grid x:Name="detailsGrid" Margin="120,0,10,10" Grid.Row="1">
    <tools:customListView ItemsSource="{Binding Items, ElementName=pageRoot}" SelectionMode="None" IsItemClickEnabled="True" Margin="5,5,0,5" HorizontalAlignment="Left" VerticalAlignment="Top" ItemClick="list_ItemClick">
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Width" Value="Auto" />
                <Setter Property="MinWidth" Value="270"/>
                <Setter Property="HorizontalAlignment" Value="Left" />
                <Setter Property="VerticalAlignment" Value="Stretch" />
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.ItemTemplate>
            <DataTemplate>
                <Border BorderThickness="{Binding BorderThickness}" BorderBrush="#cccccc" Margin="{Binding BorderMargin}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="{Binding ActualWidth, ElementName=pageRoot}"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Image Width="32" MaxWidth="32" Height="32" MaxHeight="32" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="{Binding Margin}" Source="{Binding ImageSource}" Stretch="Fill" Visibility="{Binding ImageVisibility}" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" />
                        <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Title}" TextWrapping="Wrap" FontWeight="{Binding FontWeight}" Style="{Binding StatusStyle}" />
                        <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Details}" TextWrapping="Wrap" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Visibility="{Binding DetailsVisibility}"/>
                    </Grid>
                </Border>
            </DataTemplate>
        </ListView.ItemTemplate>
    </tools:customListView>
</Grid>

这是xaml,它具有正确对齐的滚动条,但是文字换行已损坏:https://gist.github.com/paulcsiki/10388526

我需要做什么才能让屏幕右侧的滚动条和文字换行工作?

1 个答案:

答案 0 :(得分:0)

将此添加到您的ListView

ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"