WPF,Canvas上的监听事件
比较奇怪,这个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("易做图 u~");
}
}
}
--------------------编程问答-------------------- 你的Frame上是不是有其它的控件?
另外,你确定Frame有 MouseLeftButtonUp这个事件?
最后,Ctrl + Alt + S --------------------编程问答-------------------- 楼主问题解决了没,若解决了麻烦贴出解决办法,我现在也碰到同样的问题了 --------------------编程问答-------------------- 经测试<Frame Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" .../>即可,
可能Frame显示区域必须要有东东才能响应Mouse事件吧
补充:.NET技术 , .NET Framework