使用表达式混合的 wpf 应用程序的 MouseDragElement 行为
我正在尝试通过表达混合来探索行为。我在各种教程中看到过在线使用鼠标拖动,但我无法让它工作。这是示例代码 - 这就是全部内容......
<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,所以它看起来有点不同,所以也许我错过了那里的东西。
谢谢!
I am trying to explore behaviors with expression blend. I have seen the mouse drag used online in various tutorials however I can't get it to work. Here is the example code - this is the whole thing...
<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>
As far as I know I should be able to drag that button around now but it doesn't work - hmm... Is there something I am missing? Most of the tutorials I have seen use blend 3 so it looks a little different so maybe I am missing thing there.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Button 会拦截行为逻辑,因为它处理点击,如果您将 Button 替换为其他内容(例如 矩形),它应该可以工作。
The Button intercepts the Behavior logic since it handles clicks, if you replace the Button with something else like a
Rectangle
it should work.