zoukankan      html  css  js  c++  java
  • Silverlight杂记behaviors

    使用已经存在的behaviors

    1引入DLL

    image

    2在XAML中添加行为,

    在这里添加了2个,一个是拖动,一个是缓动效果

    <Rectangle x:Name="PurpleSquare" 
                    Height
    ="20" 
                    Width
    ="20" 
                    HorizontalAlignment
    ="Left" 
                    VerticalAlignment
    ="Top" 
                    Margin
    ="20" 
                    Fill
    ="BlueViolet"> 
            
    <i:Interaction.Behaviors>
               
    <ei:MouseDragElementBehavior> 拖拽效果行为
                   
    </ei:MouseDragElementBehavior>

                
    <ei:FluidMoveBehavior Duration="0:0:4">缓动 
                    
    <ei:FluidMoveBehavior.EaseX> 
                        
    <ElasticEase EasingMode="EaseOut" 
                                        Oscillations
    ="3" 
                                        Springiness
    ="4" /> 
                    
    </ei:FluidMoveBehavior.EaseX> 
                    
    <ei:FluidMoveBehavior.EaseY> 
                        
    <ElasticEase EasingMode="EaseOut" 
                                        Oscillations
    ="3" 
                                        Springiness
    ="4" /> 
                    
    </ei:FluidMoveBehavior.EaseY> 
                
    </ei:FluidMoveBehavior> 
            
    </i:Interaction.Behaviors>

    private void StartMove_Click(object sender, RoutedEventArgs e) { 
             Thickness margin 
    = PurpleSquare.Margin; 
             margin.Left 
    += 100
             margin.Top 
    += 100;
             PurpleSquare.Margin 
    = margin; 
         }

     

    自定义behaviors

    public class CustomBehavior : Behavior<Button>
      {
          protected override void OnAttached()
          {
              base.OnAttached();
              AssociatedObject.Click += new RoutedEventHandler(OnButtonClick);
          }

          protected override void OnDetaching()
          {
              base.OnDetaching();
              AssociatedObject.Click -= OnButtonClick;
          }

          void OnButtonClick(object sender, RoutedEventArgs e)
          {
              MessageBox.Show("自定义行为-!  MessageBox.Show");
          }
      }

    image

    源码下载

    https://files.cnblogs.com/facingwaller/Behaviors.rar

    扩展阅读

    BLEND下的Behaviors

    http://www.cnblogs.com/jv9/archive/2010/04/03/1703554.html

  • 相关阅读:
    java.lang.NoClassDefFoundError: org/springframework/dao/support/DaoSupport
    project configuration is not up-to-date with pom.xml
    消息列队5
    消息列队4
    消息列队3
    聊聊常见的数据库架构设计方案?
    消息队列2
    消息队列1
    搜索引擎5
    搜索引擎4
  • 原文地址:https://www.cnblogs.com/facingwaller/p/1917295.html
Copyright © 2011-2022 走看看