我正在创建一个小绘画程序,当我点击按钮时,我想要弹出一个画布。
private void buttonNewDrawing_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(mainCanvas);
}
显然不起作用,因为它要求一个字符串。但是我可以使用什么而不是MessageBox
来弹出画布mainCanvas
以便我可以使用它?
提前谢谢。
答案 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>