zoukankan      html  css  js  c++  java
  • WPF-后台代码使用Behavior

    xaml里面使用很简单

    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
    
    
     <i:Interaction.Behaviors>
        <i:MouseDragElementBehavior/>
     </i:Interaction.Behaviors>

    后台代码使用

    Microsoft.Xaml.Behaviors.Layout.MouseDragElementBehavior mouseDragElementBehavior = new Microsoft.Xaml.Behaviors.Layout.MouseDragElementBehavior();
    Microsoft.Xaml.Behaviors.Interaction.GetBehaviors(ElementName).Add(mouseDragElementBehavior);

    加上触发器

    xaml

    <TextBox x:Name="TextBoxInvoker" Text="TextBox" >
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="KeyDown" >
                <behavior:TextBoxEnterButtonInvoke TargetName="TargetedButton" />
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </TextBox>

    后台代码

    TextBoxEnterButtonInvoke textBoxEnterButtonInvoke = new TextBoxEnterButtonInvoke();
    textBoxEnterButtonInvoke.TargetName = "TargetedButton";
     
    System.Windows.Interactivity.EventTrigger eventTrigger = new System.Windows.Interactivity.EventTrigger("KeyDown");
    eventTrigger.Actions.Add(textBoxEnterButtonInvoke);
     
    System.Windows.Interactivity.Interaction.GetTriggers(TextBoxInvoker).Add(eventTrigger);
  • 相关阅读:
    Zepto结合Swiper的选项卡
    Angular选项卡
    创建简单的node服务器
    封装ajax
    JQuery和html+css实现鼠标点击放烟花
    js实现螺旋纹理特效
    Angular入门
    Angular JS例子 ng-repeat遍历输出
    Angular 基础教程(1)
    PHP数组
  • 原文地址:https://www.cnblogs.com/dangnianxiaoqingxin/p/13295163.html
Copyright © 2011-2022 走看看