<i:交互.行为>申请beahviour的选项不来了 [英] <i: Interaction.Behavior> option is not coming for applying beahviour

查看:41
本文介绍了<i:交互.行为>申请beahviour的选项不来了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图在 wpf 窗口上实现一种行为,因此我在当前的解决方案中添加了对 System.Winodws.Interactivity 的引用,然后编写了所需的行为.但为了应用这种行为,我必须在 Windows XAML 中编写类似的内容.

I have been trying to implement a behavior on a wpf window therefore I have added reference to System.Winodws.Interactivity in my current solution and then wrote the desired behavior. but in order to apply this behavior, I have to write something like this in Windows XAML.

<Window x:Class="WpfApplication5.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" 
        xmlns:behav ="clr-namespace:WpfApplication5" 
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity;assembly=System.Windows.Interactivity">
    <Window.Resources>
        <i:Interaction.Behaviors>
            <behav:DialogIconRemoveBehavior></behav:DialogIconRemoveBehavior>
        </i:Interaction.Behaviors>
    </Window.Resources>
    <Grid>

    </Grid>
</Window>

但这不是有效的标签,因为我可能必须添加对任何其他程序集的引用,除了 System.Windows.Interactivity,所以,请提出其他建议我必须这样做才能在 XAML 中使用标签

推荐答案

在浪费了我的一个小时之后,我才知道只有我必须包含 System.Windows.Interactivity 作为参考,而且我已经完成了.

After wasting my one hour I came to know that only I had to include System.Windows.Interactivity as reference and which I had already done.

问题是无法在任何控件的资源部分声明行为.

the issue was that Behaviors can not be declared in the Resource part of any control.

我拍下的那一刻

<i:Interaction.Behaviors>

</i:Interaction.Behaviors>

资源不足,然后它工作正常.

out of the resources then it worked fine.

所以,结论只有 System.Windows.Interacivity 是唯一需要的.

So, conclusion only System.Windows.Interacivity is the only required.

切勿在资源或样式中声明该行为部分.

这篇关于&lt;i:交互.行为&gt;申请beahviour的选项不来了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆