2011-05-17 117 views
2

我正在尝试探索表达式混合的行为。我在各种教程中看到了在线使用的鼠标拖动,但是我无法使其运行。下面是示例代码 - 这就是整个事情...使用表达式混合的wpf应用程序的MouseDragElementbehavior

<Window 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" mc:Ignorable="d" 
x:Class="VsmTest.MainWindow" 
x:Name="Window" 
Title="MainWindow" 
Width="640" Height="480"> 

<Grid x:Name="LayoutRoot"> 
    <Button Content="Button" Height="25" Width="100"> 
     <i:Interaction.Behaviors> 
      <ei:MouseDragElementBehavior/> 
     </i:Interaction.Behaviors> 
    </Button> 

</Grid> 

据我知道,我应该能够拖动该按钮,但现在这是行不通的 - 嗯..有什么我失踪了吗?我看过的大多数教程都使用了blend 3,所以它看起来有点不同,所以也许我在那里丢失了一些东西。

谢谢!

回答

4

按钮拦截行为逻辑,因为它处理点击,如果你用别的东西代替Button,它应该可以工作,如Rectangle