如何使用MVVM在windows phone 8.1中使用listpickerflyout

Muh*_*lah 2 c# xaml mvvm-light windows-phone

我正在寻找一个如何在MVVM Light中使用windows phone 8.1中的listpickerflyout的示例.我的要求是向用户显示一个列表,例如国家列表,用户可以从中选择一个国家/地区.显示所选国家/地区.

Muh*_*lah 7

得到解决方案:)只需要添加按钮,然后在xaml中添加listpickerflyout并绑定弹出按钮和按钮内容属性的项目源.这是怎么回事

<Button x:Name="btnTest" Content="{Binding SelectedCountry.Name, Mode=TwoWay}">
    <Button.Flyout>
        <ListPickerFlyout ItemsSource="{Binding Countries}" 
                          Placement="Full" 
                          SelectedValue="{Binding SelectedCountry, Mode=TwoWay}" 
                          DisplayMemberPath="Name"/>
    </Button.Flyout>
</Button>
Run Code Online (Sandbox Code Playgroud)