WPF中click事件无效怎么解决
xaml代码:
<Button Height="30" Width="30" Grid.Column="2" Grid.Row="0" Name="Quit"
HorizontalAlignment="Right" Margin="2" Click="Quit_Click"
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
<Button.Content>
<Image Stretch="Fill" Source="/Resources/close.png"/>
</Button.Content>
</Button>
xaml.cs代码:
private void Quit_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
运行界面这里上传不了图片,反正就是一片空白,连button里面的Image都没有显示,点击后也不进入Quit_Click
回答
问题补充:
xaml中除了布局只有按钮一个控件,也没有设置相关Resources,DataContext...