从弹出的Windows Phone 8获取用户信息

时间:2013-05-02 18:02:21

标签: windows-phone-7 popup windows-phone-8 parent-child

我有一个问题如何从PopUp控件获取用户信息? 我从msdn得到了这个代码,但我不知道如何从文本框和复选框中获取用户输入... 我只找到Windows Phone 7并且它不一样......

        Popup p = new Popup();

    private void showPopup_Click(object sender, RoutedEventArgs e)
    {
        // Create some content to show in the popup. Typically you would 
        // create a user control.
        StackPanel panel1 = new StackPanel();
        Button button1 = new Button();
        Border border = new Border();
        border.BorderBrush = new SolidColorBrush(Colors.Black);
        border.BorderThickness = new Thickness(5.0);

        panel1.Background = new SolidColorBrush(Colors.Blue);


        button1.Content = "Close";
        button1.Margin = new Thickness(5.0);
        button1.Click += new RoutedEventHandler(button1_Click);
        TextBlock textblock1 = new TextBlock();
        textblock1.FontSize = 30;
        textblock1.Text = "The popup control";
        textblock1.Margin = new Thickness(5.0);
        panel1.Children.Add(textblock1);
        panel1.Children.Add(button1);
        CheckBox cb = new CheckBox();
       cb.Name="check";
       panel1.Children.Add(cb);
       TextBox tb = new TextBox();
       tb.Name = "TB";
       panel1.Children.Add(tb);
        border.Child = panel1;
        border.Name = "BD";
        // Set the Child property of Popup to the border 
        // which contains a stackpanel, textblock and button.
        p.Child = border;

        // Set where the popup will show up on the screen.
        p.VerticalOffset = 25;
        p.HorizontalOffset = 25;

        // Open the popup.
        p.IsOpen = true;



    }

    void button1_Click(object sender, RoutedEventArgs e)
    {
        // Close the popup.
        //I need to get the info here ...
        //p.FindName("BD");//doesnt work...
        p.IsOpen = false;


    }

1 个答案:

答案 0 :(得分:0)

我建议你看看Coding4Fun Toolkit的InputPrompt。您可以在Codeplex repository上看到更多信息。

你可以按照你想要的方式设计它,它是一个经过良好测试的组件。