110,534
社区成员
发帖
与我相关
我的任务
分享
<Window x:Class="WPF4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPF4"
Title="MainWindow" Height="550" Width="725">
<Grid Background="Yellow" MouseLeftButtonDown="Grid_MouseLeftButtonDown">
<Border Name="border1" Background="Red" Height="100" Width="100" MouseLeave="Border_MouseLeave"/>
</Grid>
</Window>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Border_MouseLeave(object sender, MouseEventArgs e)
{
border1.Background = new SolidColorBrush(Colors.Black);
}
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove(); //移动窗体
}
}