2017-06-12 4 views
0

私は小さなペイントプログラムを作成しています。ボタンをクリックすると、キャンバスがポップアップされます。キャンバスを含むポップアップウィンドウを作成するにはどうすればよいですか?

private void buttonNewDrawing_Click(object sender, RoutedEventArgs e) 
{ 
    MessageBox.Show(mainCanvas); 
} 

文字列を要求しているため、明らかに機能しません。私はそれを使用することができますのでMessageBoxの代わりに何を使うことができますか?mainCanvasがポップアップしていますか?

ありがとうございます。

+0

なぜあなたは 'MessageBox'を表示したいですか? 'mainCanvas'はキャンバスコントロールですか? – Abhishek

+0

いいえメッセージボックスは、私がやりたいポップアップのタイプの例です。新しいウィンドウを開き、キャンバスを表示したいだけです。 –

答えて

1

MainWindow.xaml:

<Window x:Class="WpfApplication1.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Height="350" Width="525"> 
    <Grid> 
     <Button Click="Button_Click" Grid.Row="2" HorizontalAlignment="Center" HorizontalContentAlignment="Center" VerticalAlignment="Bottom" VerticalContentAlignment="Center" Content="Click"/> 
    </Grid> 
</Window> 

MainWindow.xaml.cs:

private void Button_Click(object sender, RoutedEventArgs e) 
{ 
    Window1 window = new Window1(); 
    window.Show(); 
} 

Window1.xaml:

<Window x:Class="WpfApplication1.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Window1" Height="300" Width="300"> 
    <Grid> 
     <Canvas /> 
    </Grid> 
</Window> 
+0

同じプロジェクトで新しいxamlを作成するにはどうすればよいですか? 私はすでにGUIの外にキャンバスを持っていますが、ボタンをクリックしたときに何とかそれを隠して表示できますか? イベントの引数がうまく見える、ありがとう! –

関連する問題