WPF popup window

前端 未结 4 852
时光取名叫无心
时光取名叫无心 2021-01-01 10:19

I would like to let the user choose their options after a button is clicked. For example, showing two buttons, \"Restart Now\" and \"Restart Later\" in a modal popup window

相关标签:
4条回答
  • 2021-01-01 10:40

    Simply show a new window with two buttons. Add property to contain user result.

    0 讨论(0)
  • 2021-01-01 10:46

    You need to create a new Window class. You can design that then any way you want. You can create and show a window modally like this:

    MyWindow popup = new MyWindow();
    popup.ShowDialog();
    

    You can add a custom property for your result value, or if you only have two possible results ( + possibly undeterminate, which would be null), you can set the window's DialogResult property before closing it and then check for it (it is the value returned by ShowDialog()).

    0 讨论(0)
  • 2021-01-01 10:47

    In WPF there is a control named Popup.

    Popup myPopup = new Popup();
    //(...)
    myPopup.IsOpen = true;
    
    0 讨论(0)
  • 2021-01-01 10:52

    XAML

    <Popup Name="myPopup">
          <TextBlock Name="myPopupText" 
                     Background="LightBlue" 
                     Foreground="Blue">
            Popup Text
          </TextBlock>
    </Popup>
    

    c#

        Popup codePopup = new Popup();
        TextBlock popupText = new TextBlock();
        popupText.Text = "Popup Text";
        popupText.Background = Brushes.LightBlue;
        popupText.Foreground = Brushes.Blue;
        codePopup.Child = popupText;
    

    you can find more details about the Popup Control from MSDN documentation.

    MSDN documentation on Popup control

    0 讨论(0)
提交回复
热议问题