在网上抄了一个让人虎躯一震的代码。。。谁能教教我怎么运行wpf的代码。。。。。。(侵删)

<window x:Name="closing" x:Class="BBdemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/bled/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BBdemo"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" Closing="closing_Closing">
<Grid>
<Grid.Background>
<ImageBrush>
</Grid.Background>
<Button Name="btnl" Content="同意" HorizontalAlignment="Left"
Margin="168,326,0,0" VerticalAlignment="Top" Width="93" Height="42"
Click="Button_Click"
/>
<Label Name="lab1" Content="表白信" HorizontalAlignment="Left"
Margin="33,44,0,0"
VerticalAlignment="Top" Height="59" Width="129"  FontSize="36" FontStyle="Italic"
/>
<Label Name="lab2" Content="你愿意做我女朋友么? &#xD;&#xA;&#x9;"
HorizontalAlignment="Left"  Height="60" Margin="493,200,0,0"
VerticalAlignment="Top"
width="281" FontSize="36"/>
<Button Name="btn3" Visibility="Hidden" Content="退出" HorizontalAlignment="left"
 Height="42" Margin="326,326,0,0" VerticalAlignment="Top" Width="90"
 Click="Button_Click_1"/>

 <Image Margin="206,10,316,6,109" Source="biaobai.png" Stretch="Fill">
 <Button Name="btn2" Content="不同意" HorizontalAlignment="Left"
 Margin="493,326,0,0" VerticalAlignment="Top" Width="93" Height="42"
 MouseEnter="Button_MouseEnter"/>
 </Grid>
/window>
using System;
using System Collections.Generic;
using System Linq;
using System Text;
using System Threading Tasks;
using System Windows;
using System Windows.Controls;
using System Windows.Data;
using System Windows.Documents;
using System Windows.Input;
using System Windows.Media;
using System Windows.Media.Imaging;
using System Windows.Navigation ;
using System Windows.Shapes;
namespace BBdemo
{
public partial class MainWindow:Window
{
public MainWindow()
{
InitializeComponent();
}
private  void Button_MouseEnter(object,sender,MouseEventArgs e)
{
Random rd=new Random();
Button btn=sender as Button;
double maxW=this.Width;
double maxH=this.Height;
double w=btn.Width;
double h=btn.Height;
double l=rd.Next(0,(int)(maxW-w));
double t=rd.Next(0,(int)(maxH-h));
btn.Margin=new Thickness(1,t,0,0);
}
private void closing_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
MessageBox.Show("关不掉!");
e.Cancel=true;
}
private Button_Click(object sender , RoutedEventArgs e)
{
lab1.Visibility=System.Windows.Visibility.Hidden;
lab2.Content="谢谢女朋友";
btn3.Visibility=System.Windows.Visibility.Visible;
btn1.Visibility=System.Windows.Visibility.Hidden;
btn2.Visibility=System.Windows.Visibility.Hidden;
}
private void Button_Click_1(object sender , RoutedEventArgs e )
{
System.Environment.Exit(0);
}
}
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值