1

我想仅使用转换来反转 ListBox 中的项目。我有这个尝试(下)。但是,我希望右侧的项目从顶部向下流动。有人能看到怎么做吗?

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.Resources>
            <Style TargetType="ListBoxItem" x:Key="R">
                <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <ScaleTransform ScaleX="1" ScaleY="-1"/>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ListBox>
            <ListBoxItem>A</ListBoxItem>
            <ListBoxItem>B</ListBoxItem>
            <ListBoxItem>C</ListBoxItem>
            <ListBoxItem>D</ListBoxItem>
            <ListBoxItem>E</ListBoxItem>
            <ListBoxItem>F</ListBoxItem>
        </ListBox>
        <ListBox Grid.Column="1" RenderTransformOrigin="0.5,0.5">
            <ListBox.RenderTransform>
                <ScaleTransform ScaleX="1" ScaleY="-1"/>
            </ListBox.RenderTransform>
            <ListBoxItem Style="{StaticResource R}">V</ListBoxItem>
            <ListBoxItem Style="{StaticResource R}">U</ListBoxItem>
            <ListBoxItem Style="{StaticResource R}">W</ListBoxItem>
            <ListBoxItem Style="{StaticResource R}">X</ListBoxItem>
            <ListBoxItem Style="{StaticResource R}">Y</ListBoxItem>
            <ListBoxItem Style="{StaticResource R}">Z</ListBoxItem>
        </ListBox>
    </Grid>
</Window>
4

1 回答 1

1

我找到了我要找的东西。这VerticalAlignment是踢球者:

<ListBox.ItemsPanel>
    <ItemsPanelTemplate>
        <VirtualizingStackPanel VerticalAlignment="Top" Orientation="Vertical">
            <VirtualizingStackPanel.LayoutTransform>
                <ScaleTransform ScaleX="1" ScaleY="-1" />
            </VirtualizingStackPanel.LayoutTransform>
        </VirtualizingStackPanel>
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>

相关来源:WPF View ListView Backwards

于 2014-07-07T20:22:05.360 回答