0

我有一个问题如何从 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;


    }
4

1 回答 1

0

我建议你看看 Coding4Fun Toolkit 的 InputPrompt。您可以在Codeplex 存储库上查看更多信息。

您可以按照您想要的方式对其进行样式设置,并且它是一个经过良好测试的组件。

于 2013-05-02T18:31:10.930 回答