精华内容
参与话题
问答
  • Behavior

    2019-03-03 12:08:00
    Behavior翻译是行为 在WPF中Behavior的使用时必须引用Blend的程序集。 ‪C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.5\Libraries\System.Windows.Interactivity.dll System....

    Behavior翻译是行为

    在WPF中Behavior的使用时必须引用Blend的程序集。

    ‪C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.5\Libraries\System.Windows.Interactivity.dll

     System.Windows.Interactivity;

     

    或者通过Nuget包管理来获取。

     

    现在来说说如果使用

    behavior是行为,而这个行为是针对控件的。

    就目前WPF添加行为的方式可以有附加属性 附加事件 依赖属性等方法。

    就特性而言behavior和附加属性很相似。

    那么使用方式:

    1. 创建一个由Behavior<DependencyObject>所派生的类

    2. 创建依赖属性(不用回调方法)

    3. 根据你想要的效果来重写Behavior的方法

    4. 在xaml中使用

      public class ATCH : Behavior<System.Windows.Controls.TextBox>
        {
            public static readonly DependencyProperty BackRedProperty = DependencyProperty.Register("BackRed", typeof(bool), typeof(ATCH), new PropertyMetadata(false, null));
              
            public bool BackRed
            {
                get { return (bool)GetValue(BackRedProperty); }
                set { SetValue(BackRedProperty,value); }
            }
          
            
            /// <summary>
            /// 当behavior附加成功时
            /// </summary>
            protected override void OnAttached()
            {
                base.OnAttached();
               
            }
            /// <summary>
            /// 当behavior分离时
            /// </summary>
            protected override void OnDetaching()
            {
                base.OnDetaching();
            }
    
            /// <summary>
            /// 当属性变化时
            /// </summary>
            /// <param name="e"></param>
            protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
            {
                if ((bool)e.NewValue)
                    AssociatedObject.Background = new SolidColorBrush(Colors.Red);
                else
                    AssociatedObject.Background = new SolidColorBrush(Colors.Gainsboro);
            }
            /// <summary>
            /// 当属性变化
            /// 此方法触发在OnPropertyChanged后
            /// </summary>
            protected override void OnChanged()
            {
                base.OnChanged();
               
            }
        }

    而在xaml中则是

     

    <Window x:Class="Beh.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:Beh"
            
            xmlns:AT="http://schemas.microsoft.com/expression/2010/interactivity" 
          
            mc:Ignorable="d" 
            Title="MainWindow" Height="450" Width="800">
        <Grid>
            <TextBox    Margin="211,147,191,124">
                <AT:Interaction.Behaviors>
                    <local:ATCH BackRed="False"  />
                </AT:Interaction.Behaviors>
            </TextBox>
        </Grid>
    </Window>

     

    转载于:https://www.cnblogs.com/T-ARF/p/10464604.html

    展开全文
  • RFC: Behavior

    2020-11-23 11:13:28
    <ul><li>A behavior is an object with type parameters</li><li>The Spec parameter is the thing that you pass when loading the behavior, usually a configuration object</li><li>The Value parameter is the ...
  • <div><p>I create a custom behavior but I have some problems to use in my project... <p>I see the code of <code>Propel\Generator\Util\BehaviorLocator</code> and I understand that it load the behaviors ...
  • <div><p>I wanted to ask if the following enter key behavior would be something that you would consider accepting, before I try to add it in a PR. <p><strong>State:</strong> an option is highlighted in...
  • Behavior Designer 1.6.1

    2019-01-10 11:47:51
    使用Behavior Designer,您可以将行为树的强大功能带到Unity! 行为设计器是一种为每个人设计的行为树实现 - 程序员,艺术家,设计师。 Behavior Designer提供直观的可视化编辑器和强大的API,使您可以轻松创建新...
  • <p>This PR fixes all these bugs by introducing a slight change of behavior: the point set now stores the <em>number</em> of selected points. The correct iterator is recomputed when needed (the ...
  • Behavior trees are used by AAA studios to create a lifelike AI. With Opsive's Behavior Designer, you can bring the power of behaviour trees to Unity! Behavior Designer is a behaviour tree ...
  • Behavior Designer 是一个行为树插件!是为了让设计师,程序员,美术人员方便使用的可视化编辑器!Behavior Designer 提供了强大的 API 可以让你轻松的创建 tasks(任务),配合 uScript 和 PlayMaker 这样的插件,...
  • <div><h3>Expected Behavior <p><em>Please describe what should happen</em></p> <p>Both of these sprites have a "forever if touching other sprite say hello" stack running <img alt="dragging-...
  • With research from leading scientists, Sedentary Behavior and Health: Concepts, Assessments, and Intervention presents evidence on sedentary behavior, its apparent health risks, and suggestions on ...
  • Behavior trees are used by AAA studios to create a lifelike AI. With Opsive's Behavior Designer, you can bring the power of behaviour trees to Unity! Behavior Designer is a behaviour tree ...
  • Behavior trees are used by AAA studios to create a lifelike AI. With Behavior Designer, you can bring the power of behaviour trees to Unity! Behavior Designer is a behaviour tree implementation ...
  • unity角色行为AI系统Behavior Designer - Movement Pack 1.5.4 所支持的Unity版本:4.6.0 及以上版本 Requires Behavior Designer Behavior Designer - Movement Pack contains 17 different behaviour tree tasks ...
  • <div><p>The new behavior of <code>C+l, e</code> becomes <pre><code>latex \begin{} \end{} </code></pre> <p>with two cursors appearing in the braces. Now, to add contents inside the environment, ...
  • <div><p>Is there a way to simulate the native IOS photo gallery behavior like this: - when image is completely zoomed out: swipe left/right would navigate to previous/next image in the set - when zoo...
  • Behavior Designer is dedicated to behavior trees, which means that each update will be a better behavior tree implementation. Features: - An intuitive visual editor - A powerful API - Visual ...
  • <p>What I want is a way to disable the standard card fields and this new inline behavior and want my integration to follow the old behavior which opens up a guest checkout modal on clicking on a card ...
  • Behavior Designer 1.6.4.rar

    2020-04-17 16:12:21
    Behavior Designer 是一个行为树插件!是为了让设计师,程序员,美术人员方便使用的可视化编辑器!Behavior Designer 提供了强大的 API 可以让你轻松的创建 tasks(任务),配合 uScript 和 PlayMaker 这样的插件,...
  • Behavior Designer最新版1.6.6 - Behavior Trees for Everyone

空空如也

1 2 3 4 5 ... 20
收藏数 120,612
精华内容 48,244
关键字:

behavior