界面代码
<Window x:Class="YourNamespace.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 MouseDown="Grid_MouseDown">
<!-- Your grid content goes here -->
</Grid>
</Window>
后台代码
using System.Windows;
using System.Windows.Input;
namespace YourNamespace
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
{
// 处理鼠标单击事件
if (e.ClickCount == 2)
{
// 在这里添加双击事件的处理逻辑
}
}
}
}