WPF,Canvas上的监听事件

Youdonotsay 2010-04-15 03:11:40
比较奇怪,这个MouseLeftButtonUp的事件不能用。
求解释。谢。


<Window x:Class="WPFTest1.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 Margin="30.906,27.27,35.451,86.355" Name="canvas1">
<Frame Canvas.Left="6" Canvas.Top="6" Height="136.375" Name="frame1" Width="199.98" MouseLeftButtonUp="frame1_MouseLeftButtonUp_1" />
</Canvas>
</Grid>
</Window>

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Shapes;
using System.Windows.Controls.Primitives;
using System.Windows.Media.Animation;

namespace WPFTest1
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}

private void frame1_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("fuck u~");
}
}
}
...全文
399 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
heguo 2010-05-26
  • 打赏
  • 举报
回复
经测试<Frame Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" .../>即可,
可能Frame显示区域必须要有东东才能响应Mouse事件吧
lensso 2010-05-26
  • 打赏
  • 举报
回复
楼主问题解决了没,若解决了麻烦贴出解决办法,我现在也碰到同样的问题了
zsuswy 2010-04-16
  • 打赏
  • 举报
回复
你的Frame上是不是有其它的控件?
另外,你确定Frame有 MouseLeftButtonUp这个事件?

最后,Ctrl + Alt + S

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧