X:将绑定下拉列表绑定到绑定列表

我一直想弄清楚如何将下拉列表绑定到绑定列表框。 我想显示一个包含所有乘客及其座位号的列表,显示在下拉列表中。管理员应该能够通过下拉列表更改乘客的座位号。

我尝试研究嵌套绑定,但是找不到任何提及我的问题的东西。

XAML

<Page
    x:Class="FlightApplication.Passengers"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FlightApplication"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:fdata="using:FlightApplication.Models"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <ListBox x:Name="ListBox1" Margin="5" Width="450" Height="200" HorizontalAlignment="Left" ItemsSource="{x:Bind PassengersList}" FontFamily="Segoe UI">
        <ListBox.ItemTemplate>
            <DataTemplate x:Name="PassengerLineTemplate" x:DataType="fdata:Passenger">
                <StackPanel Orientation="Vertical" Margin="2">
                    <TextBlock>
                        <Run Text="{x:Bind LastName}"/>
                        <Run Text=" "/>
                        <Run Text="{x:Bind FirstName}"/>
                    </TextBlock>
                    <TextBlock>
                        <Run Text="{x:Bind Class}"/>
                        <Run Text=" - "/>
                        <Run Text="{x:Bind SeatNr}"/>
                    </TextBlock>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
        </ListBox>
</Page>
namespace FlightApplication
{
    public sealed partial class Passengers : Page
    {
        public ObservableCollection<Passenger> PassengersList = new ObservableCollection<Passenger>();
        public Passengers()
        {
            this.InitializeComponent();
            //ListBox1.DataContext = PassengersList; Do i use this?


        }
    }
}
c7949138 回答:X:将绑定下拉列表绑定到绑定列表

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3128003.html

大家都在问