【问题标题】:isEnabled binded to other button clickisEnabled 绑定到其他按钮单击
【发布时间】:2017-04-07 15:53:32
【问题描述】:

我无法弄清楚我缺少哪个资源才能使其正常工作,我收到消息 ei namespace is not found。

        <Button 
         Name="btnEnter"
        Click="btnEnter_Click"
        Style="{StaticResource SignButtons}"
        FontFamily="Comic"
        FontSize="24"
        FontWeight="DemiBold"
        Grid.Column="3" 
        Height="51.562"
        Width="75"
        Margin="30,23.624,0,0"
        Grid.Row="3"
        Template="{DynamicResource EnterButton}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <ei:ChangePropertyAction 
                    TargetObject="{Binding ElementName=btnMultiplication}" 
                    PropertyName="IsEnabled" Value="False"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>

这里是命名空间

<Window x:Class="Button_Template.MainWindow"
    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:local="clr-namespace:Button_Template"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/netfx/2009/xaml/presentation"

    mc:Ignorable="d"

【问题讨论】:

  • 向我们展示来自 XAML 根元素的 XML 命名空间,应该很容易发现。
  • 尝试添加这个xmlns xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
  • 我已经添加了命名空间,现在错误消息不同了 - ChangePropertyAction 不存在于 "clr-namespace:Microsoft.Expression.Interactivity.C‌​ore;assembly=Microso‌​ft.Expression.Intera‌​动作”

标签: wpf xaml


【解决方案1】:

ChangePropertyAction 类型在 Microsoft.Expression.Interactions.dll 中定义。它不是 .NET Framework 的一部分,但您可以使用 NuGet 下载此程序集:https://www.nuget.org/packages/MicrosoftExpressionInteractions/

或者您可以从这里下载 Blend SDK 并添加对它的引用:https://www.microsoft.com/en-us/download/details.aspx?id=10801

XAML 命名空间映射应该是:

xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"

【讨论】:

    【解决方案2】:

    我建议您在添加 ChangePropertyActionCallMethodAction 等内容时遵循这些步骤... 1. 转到 Blend 并打开您的项目,然后选择要在其中插入 ChangePropertyAction 的控件

    添加ChangePropertyAction 后,Blend 会自动添加 xmlns 扩展。

    因此您不必手动操作。将其保存在 blend 中后,只需转到 VS 并重新加载您的项目并继续。

    重要提示将在“对象和时间轴”窗口中的选定控件上添加交互。

    【讨论】:

    • 我已按照您的说明进行操作,但是当我将 ChangePropertyAction 拖到对象和 TimeLine 中的 myButton 上时,我收到消息:在 Button 中创建 ChangePropertyAction。我点击但没有任何反应。有没有组合键可以完成这个操作?
    • 没什么特别的。我只是选择控件,并在行为>>ChangePropertyAction 中使用 doubleClick 并自动将其添加到按钮。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-12
    • 2012-06-02
    • 2018-01-21
    • 2011-08-26
    • 2015-12-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多