创建一个ListBox,其中包含选中时展开的项目(Accordion)

Gab*_*och 5 c# xaml listbox uwp

对于基于XAML的旧UI框架(WPF/SL),这个问题有解决方案,但它们不容易适应通用Windows平台.

我正在尝试创建一个项目列表,这些项目仅显示默认状态下的有限详细信息,并在选中时进行扩展以快速编辑某些数据.
我没有找到一种方法来创建这种扩展行为,虽然它与Windows 10 Mail应用程序的操作类似,但仍有对话.当选择对话消息时,该对话的其他消息会下拉或向下滑动.

下面是一个列表示例,我想首先只显示名称.

<ListBox ItemsSource="{x:Bind Persons}">
    <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        </Style>
    </ListBox.ItemContainerStyle>
    <ListBox.ItemTemplate>
        <DataTemplate x:DataType="src:Person">
            <StackPanel HorizontalAlignment="Stretch" Width="Auto">
                <TextBlock Text="{x:Bind Path=Name, Mode=OneWay}" Margin="12, 15, 12, 0" FontSize="18.667" />
                <TextBox HorizontalAlignment="Stretch" Margin="12, 12, 12, 0" FontSize="18.667" Text="{x:Bind Path=Name, Mode=TwoWay}" />
                <TextBlock Text="Date of birth" Margin="12, 15, 12, 0" />
                <DatePicker Margin="12, 5, 12, 0" Date="{x:Bind Path=DateOfBirth, Mode=TwoWay}" />
                <TextBlock Text="Domicile" Margin="12, 15, 12, 0" />
                <TextBox Margin="12, 5, 12, 0" Text="{x:Bind Path=Domicile, Mode=OneWay}" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)

在WPF中,这种行为可以通过触发器实现,Style.Triggers但它们不再可用.

GitHub上的原始源代码

nor*_*r0x 0

ListView为 UWP 创建了一个可扩展控件 - 您可以在 GitHub 存储库中找到。它实际上是一个移植版本,WPF Expander我对其进行了修改,以便与通用 Windows 平台一起使用。

您可以在StackOverflow上找到我的问题和答案。