Create a custom behavior and use 2 in the Silverlight Project

Source: Internet
Author: User

Preface

Because a sensitive word never wants to use this titleArticleFor the continuity, I just need two times, huh, huh.

First, let's add the custom behaviors created in expression blend called in expression blend described in "create a custom behavior and use it in Silverlight project ".Code.

Open the Silverlight project. [Note: If the behaviors you created is Silverlight, it can only be used in the Silverlight project. The same applies to WPF.] add reference for custom behavior, as shown in figure


After adding a reference, you need to re-compile the project to add the behavior to the current project. After compilation, we open the asset (asset) panel and you will find that the created mybehavior appears.


Drag a textbox to the beautification board to apply mybehavior and drag mybehavior to the textbox, as shown in figure


Navigate to the properties panel. We can set the foreground font to red or other brushes to runProgram, We run the same results

 

This article describes triggeraction and related knowledge.

 

What is triggeraction?

It can be understood literally that the action of the trigger is defined, which is explained by msdn:

Describes an action to perform for a trigger

When writing a class that inherits from triggeraction, we do not need to register an event in the onattached method as behavior, and remove the event in the ondetaching method.Triggeraction assume that you want to obtain an event. All you need to do is provide an invoke method, which will be called when the event is triggered..

To make everyone better understand this, we can view some of the behaviors that come with expression blend.Source code[The behaviors inherent in expression blend exist in Microsoft. expression. Interactions. dll]

Let's look at a simple class inherited from triggeraction-hyperlinkaction.

We can see that it has two dependency attributes and an invoke method. Let's take a look at what has been done in the invoke method.

In the invoke method, the navigation operation is written. Then, in the expression blend operation, add hyperlinkaction to the button. Its Attribute panel is as follows, including triggers, trigger conditions, and attributes inherent in hyperlinkaction (defined in the Code): navigationuri and targetwindow [Default: _ self]

Trigger and trigger conditions are inherited from triggeraction and are the class diagrams of triggeraction.

You can see that the triggeraction class has the invoke method, as well as the onattached method and ondetaching method in the behavior class. The following figure better shows that the default event in expression blend is click.

 

In this article, we will not use a specific demo to write another behavior that inherits to triggeraction. You can refer to hyperlinkaction. In addition, the source code includes the Code involved above.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.