Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Great answer of Josh, all credit to him, I slightly modified it to this however:</p> <p>MyDialog Xaml</p> <pre><code> &lt;StackPanel Margin="5,5,5,5"&gt; &lt;TextBlock Name="TitleTextBox" Margin="0,0,0,10" /&gt; &lt;TextBox Name="InputTextBox" Padding="3,3,3,3" /&gt; &lt;Grid Margin="0,10,0,0"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Button Name="BtnOk" Content="OK" Grid.Column="0" Margin="0,0,5,0" Padding="8" Click="BtnOk_Click" /&gt; &lt;Button Name="BtnCancel" Content="Cancel" Grid.Column="1" Margin="5,0,0,0" Padding="8" Click="BtnCancel_Click" /&gt; &lt;/Grid&gt; &lt;/StackPanel&gt; </code></pre> <p>MyDialog Code Behind</p> <pre><code> public MyDialog() { InitializeComponent(); } public MyDialog(string title,string input) { InitializeComponent(); TitleText = title; InputText = input; } public string TitleText { get { return TitleTextBox.Text; } set { TitleTextBox.Text = value; } } public string InputText { get { return InputTextBox.Text; } set { InputTextBox.Text = value; } } public bool Canceled { get; set; } private void BtnCancel_Click(object sender, System.Windows.RoutedEventArgs e) { Canceled = true; Close(); } private void BtnOk_Click(object sender, System.Windows.RoutedEventArgs e) { Canceled = false; Close(); } </code></pre> <p>And call it somewhere else</p> <pre><code>var dialog = new MyDialog("test", "hello"); dialog.Show(); dialog.Closing += (sender,e) =&gt; { var d = sender as MyDialog; if(!d.Canceled) MessageBox.Show(d.InputText); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload