Windows Phone 8.1 Flyout

network | | 访问(60)
<StackPanel>
    <Button Content="Show Flyout">
        <Button.Flyout>
            <Flyout>
                <StackPanel >
                    <TextBox PlaceholderText="请输入名字"/>
                    <Button HorizontalAlignment="Right" Content="确定"/>
                </StackPanel>
            </Flyout>
        </Button.Flyout>
    </Button>
    <Button x:Name="menuFlyoutButton" Content="Show MenuFlyout" >
        <Button.Flyout >
            <MenuFlyout>
                <MenuFlyoutItem Text="Option 1" Click="MenuFlyoutItem_Click"/>
                <MenuFlyoutItem Text="Option 2" Click="MenuFlyoutItem_Click"/>
                <MenuFlyoutItem Text="Option 3" Click="MenuFlyoutItem_Click"/>
            </MenuFlyout>
        </Button.Flyout>
    </Button>
    <Button Content="Show DatePicker" >
        <Button.Flyout>
            <Controls:DatePickerFlyout Title="选择日期:"  DatePicked="DatePickerFlyout_DatePicked"/>
        </Button.Flyout>
    </Button>
    <Button Content="Show TimePicker" >
        <Button.Flyout>
            <Controls:TimePickerFlyout Title="选择时间:"  TimePicked="TimePickerFlyout_TimePicked"/>
        </Button.Flyout>
    </Button>
    <Button Content="Show Picker" >
        <Button.Flyout>
            <Controls:PickerFlyout   Confirmed="PickerFlyout_Confirmed" ConfirmationButtonsVisible="True">
                <TextBlock Text="你确定吗?????" FontSize="30" Margin="0 100 0 0"/>
            </Controls:PickerFlyout>
        </Button.Flyout>
    </Button>
    <Button Content="Show ListPicker">
        <Button.Flyout>
            <Controls:ListPickerFlyout x:Name="listPickerFlyout" Title="选择手机品牌:" ItemsPicked="listPickerFlyout_ItemsPicked"  >
                <Controls:ListPickerFlyout.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" FontSize="30"></TextBlock>
                    </DataTemplate>
                </Controls:ListPickerFlyout.ItemTemplate>
            </Controls:ListPickerFlyout>
        </Button.Flyout>
    </Button>
    <TextBlock Text="请点击我!" Tapped="TextBlock_Tapped" FontSize="20">
                        <FlyoutBase.AttachedFlyout>
                            <Flyout>
                                <TextBox Text="你好!"/>
                            </Flyout>
                        </FlyoutBase.AttachedFlyout>
    </TextBlock>
</StackPanel>
public sealed partial class MainPage: Page {
    public MainPage() {
        this.InitializeComponent();
        listPickerFlyout.ItemsSource = new List < string > {
            "诺基亚",
            "三星",
            "HTC",
            "苹果",
            "华为"
        };
    }

    private async void PickerFlyout_Confirmed(PickerFlyout sender, PickerConfirmedEventArgs args) {
        await new MessageDialog("你点击了确定").ShowAsync();
    }

    private async void TimePickerFlyout_TimePicked(TimePickerFlyout sender, TimePickedEventArgs args) {
        await new MessageDialog(args.NewTime.ToString()).ShowAsync();
    }

    private async void DatePickerFlyout_DatePicked(DatePickerFlyout sender, DatePickedEventArgs args) {
        await new MessageDialog(args.NewDate.ToString()).ShowAsync();
    }

    private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e) {
        menuFlyoutButton.Content = (sender as MenuFlyoutItem).Text;
    }

    private void TextBlock_Tapped(object sender, TappedRoutedEventArgs e) {
        FrameworkElement element = sender as FrameworkElement;
        if (element != null) {
            FlyoutBase.ShowAttachedFlyout(element);
        }
    }

    private async void listPickerFlyout_ItemsPicked(ListPickerFlyout sender, ItemsPickedEventArgs args) {
        if (sender.SelectedItem != null) {
            await new MessageDialog("你选择的是:" + sender.SelectedItem.ToString()).ShowAsync();
        }
    }

    protected override void OnNavigatedTo(NavigationEventArgs e) {}

}