Making it Easier to Write Behaviors

July 9th, 2009     |     View Comments

Behaviors make it easier for designers to be able to do cool things that would otherwise require writing code. Of course, a behavior doesn’t just magically appear out of thin air.* It requires someone actually writing it.

While one our goals was to make it easy for someone to write a Behavior, there is a certain amount of boilerplate code that you need to be aware of before you get to writing code that is more familiar to you. To help make that process easier, we are going to be providing Item Templates that can be accessed from both Expression Blend 3 as well as Visual Studio 2008.

Here are the Action, Behavior, and Trigger item templates in Blend 3:

baction

…and here they are in Visual Studio:

vs_item_templates

These item templates contain the boilerplate code I referred to earlier, so with a few clicks, you are up and running with something that Blend recognizes as a Behavior, Action, or Trigger

For example, here is what a Trigger looks like when created via our Item Template:

public class Trigger1 : TriggerBase<DependencyObject>
{
protected override void OnAttached()
{
base.OnAttached();
 
// Insert code that you want to run when the Trigger is attached to an object.
}
 
protected override void OnDetaching()
{
base.OnDetaching();
 
// Insert code that you would want run when the Trigger is removed from an object.
}
 
//
// To invoke any associated Actions when this Trigger gets called, use
// this.InvokeActions(o) where o is an object that you can pass in as a parameter
//
}
 

We create all of the infrastructure code that makes your Trigger a trigger, and we also provide you with some helpful comments on what to do. Because our behaviors functionality requires referencing a DLL that we provide, that referencing step is taken care of automatically for you as well. Wouldn’t it be great if everything in life were as simple as this? Ok, I’ll stop now! :P

How this is Possible
Everything I’ve written above uses the Item Templates format documented on MSDN. What is new is how these templates get installed. We will be releasing in the near future a standalone Expression Blend SDK that makes it possible for you to create and redistribute the various new components we introduced as a part of Blend 3. You can read more about this on a blog post I wrote for the Expression Blend & Design team blog.

Cheers!
Kirupa :)

*That feature is currently being prototyped in an underground bunker in an undisclosed location.

View Comments to “Making it Easier to Write Behaviors”

  1. Rahul Says:

    I want to know how to use SQL server 2005/08 with WPF. can you cover that if your next blog posts. It’ll help a lot.

  2. Cory Plotts’ Blog » Silverlight 3 Launches and Blend 3 RC is Released Says:

    [...] improvements (for example, the direct selection improvements) … but what about behaviors (1, 2, 3)? Whoa! Can we say [...]

  3. 30 grandes post y tutoriales de Silverlight 3 y Blend 3 - Blog de Oskar Alvarez Says:

    [...] Behavior Templates for Blend and Visual Studio – Kirupa shares some ItemTemplates to help when creating new Actions, Behaviors and Triggers [...]

  4. ManniAT Says:

    Great thing – but it doesn’t the item templates do not show up in localized versions of VS2008.
    I wrote a short description how to fix this
    http://manni-at.spaces.live.com/blog/cns!82CF2A6C0D0C6F3C!203.entry

  5. 30 grandes post y tutoriales de Silverlight 3 y Blend 3 at Comunidad Gunet México Says:

    [...] Behavior Templates for Blend and Visual Studio – Kirupa shares some ItemTemplates to help when creating new Actions, Behaviors and Triggers [...]

  6. Beat and Byte » 30 grandes post y tutoriales de Silverlight 3 y Blend 3 Says:

    [...] Behavior Templates for Blend and Visual Studio – Kirupa shares some ItemTemplates to help when creating new Actions, Behaviors and Triggers [...]

  7. 30 Great Posts and Tutorials on Silverlight and Blend 3 - AdamKinney.com Says:

    [...] Behavior Templates for Blend and Visual Studio – Kirupa shares some ItemTemplates to help when creating new Actions, Behaviors and Triggers [...]

  8. 30 Great Posts and Tutorials on Silverlight and Blend 3 « Adam Kinney Says:

    [...] Behavior Templates for Blend and Visual Studio – Kirupa shares some ItemTemplates to help when creating new Actions, Behaviors and Triggers [...]

  9. Ted Cronin Says:

    The VentureIntoGaming_ExpressionBlend3_StarterKit is password protected, any ideas?

  10. T Burger Says:

    I am creating a behavior and would like to add a dependency that the user chooses and object off the story board with the target chooser. I can’t seem to figure out how to do this. Any direction you can point me in is apriciated.

  11. buy cheap music Says:

    Heya! I just wanted to ask if you ever have any problems with hackers? My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no data backup. Do you have any solutions to stop hackers?
    http://www.cheapmusicsites.com

  12. link wheel Says:

    Excellent information here. This attention-grabbing publish made me smile. Possibly when you throw in a couple of footage it’s going to make the entire thing more interesting. Anyway, in my language, there should not much good source like this.

  13. cabbage soup diet Says:

    Thank you for the wise critique. Me & my neighbour had been making ready to do some research about that. We obtained a superb guide on that matter from our native library and most books where not as influensive as your information. I am very glad to see such information which I was searching for a protracted time.This made very glad! Anyway, in my language, there are not much good source like this.

  14. south beach diet recipes Says:

    I was in search of crucial info on this subject. The knowledge was essential as I am about to launch my very own portal. Thanks for offering a lacking link in my business. Anyway, in my language, there usually are not a lot good source like this.

  15. link wheel Says:

    Loved this post!! If we met that millionaire at the same time, beware. I can be ruthless, cunning, and stubbornly determined. All is fair in love and dream jobs. Selling my soul is not off the table. ;-)

  16. dich vu seo Says:

    Hey cool blog, just wondering what anti-spam software program you use for comments as a result of i get heaps on my blog. Anyway, in my language, there usually are not a lot good source like this.

  17. bp claims Says:

    How come my comment does not stick?

  18. cabbage soup diet Says:

    Took me time cabbage soup diet to learn all of the comments, however I really enjoyed the article. It proved to be very useful to me and I’m certain to all of the commenters right here! cabbage soup diet It’s all the time nice when you cannot solely learn, but additionally engaged! I’m certain you had joy scripting this cabbage soup diet article. cabbage soup diet Anyway,cabbage soup diet in my language, there aren’t a lot good source like this.cabbage soup diet

  19. linkwheel Says:

    I used to be linkwheel questioning if you would linkwheel like to be a visitor poster on linkwheel my web site? and in trade you may embody a hyperlink your post? linkwheel Please reply when you get an opportunity and I linkwheel will send you my contact particulars – thanks. Anyway, in my language, there aren’t linkwheel much good source like this.

  20. cover letter help Says:

    Aww, I hurt your tiny ego.
    But anyway, Im curious as to where you picked up the first few insults from, that too in clear grammar. Impressive, for you I mean. Youre probably the first person Ive heard call himself a poet, Im not doing that (yes, in reference to Neruda. No one can be Neruda, asshole, not even you, or your mommy who writes poetry in a journal-and your probably thought you should give it a hand). Im just writing something, people call it free verse, I call them ideas.

  21. Advertising Sales Jobs Says:

    I’m a Sprouting Artist and loving it. I love to tell stories and I’m learning how as a student at BYU-I. I’m inspired by my peers, teachers and husband. I hope one of my images make you smile! Enjoy.

  22. discount tire coupons Says:

    Thanks for some other wonderful post. Where else could anyone get that kind of information in such an ideal way of writing? I have a presentation next week, and I’m at the search for such information.

  23. true religion outlet Says:

    I read with great interest.Thanks for you sharing.

  24. video games jobs Says:

    Hey there, You’ve done a great job. I’ll definitely digg it and personally recommend to my friends. I am sure they will be benefited from this web site.

  25. delray beach seo Says:

    It appears that you’ve put a number of effort and onerous work into your post and I require far more of those on the web in current times. I sincerely obtained a kick out of your post. I don’t really have considerably to say responding, I only wanted to comment to answer amazing work.

  26. Bradman Jack Says:

    I am interested to create a behavior. And also I would like to add a dependency that the user chooses and article off the adventure lath with the ambition chooser. It is a great thing. 

    link wheel creation

  27. merchant advance loan Says:

    I’ve recently started a website, the information you provide on this website has helped me tremendously. Thank you for all of your time & work.

  28. teenage party themes Says:

    This is very interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your wonderful post. Also, I’ve shared your site in my social networks!

  29. Food as Medicine Says:

    Tanks for the item templates i found them pretty helpfull.

  30. kettlebells Says:

    appurtenant googled throughout to your site. sound is a path toto stunning doorpost. aye what I was attempting in that.

  31. online opportunity Says:

    Just wish to say your article is as astonishing. The clearness in your post is just great and i could assume you’re an expert on this subject. Well with your permission let me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please continue the rewarding work.

  32. Diana Wainkrantz Says:

    Thank you for the post, I don’t agree completely with it but I agree with it on the most part and I certainly applaud your effort in putting it so succinctly.

  33. Milo Surridge Says:

    if they take Lucas and Peyton off the show is simply going to be cancelled who knws maybe theyl just be taking them off for the first few episodes

  34. shane radbone Says:

    I admire the beneficial information and facts you provide in your posts. I will bookmark your blog and also have my children check up right here generally. I am fairly sure they’ll discover a lot of new things right here than anyone else!

  35. Cell Phone Accessories Says:

    I love this . do you have fan facebook page for your site ?

  36. Sell My House Fast UK, Says:

    I need to agree that this blog is worth all my time spent in studying it. Individuals posting weblog should really exert some effort to educating the readers.This would be the wonderful weblog for anyone who desires to find out about this subject.

  37. xinwei Says:

    Thank you for that smart critique. Me & my neighbour were preparing to do some research about that. We obtained a great book on that matter from our local library and most books exactly exactly where not as influensive as your info. I am extremely glad to see such info which I was searching for a lengthy time.

  38. xixihaha567 Says:

    Truly liked going via this. Maintain it up!

  39. logitech g11 Says:

    Thanks for good info. It’s helpful for me. Are you able to give me some more data with details? I will wait in your next post.

  40. Numbers Saice Says:

    I really treasure your piece of work, Great post.

  41. Kerrie Sar Says:

    I am lucky that I discovered this website just the right information that I was searching for

  42. litchney law firm Says:

    Fantastic blog! Do you have any helpful hints for aspiring writers? I’m planning to start my own website soon but I’m a little lost on everything. Would you advise starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m completely confused .. Any suggestions? Thanks!

  43. Howard Kues Says:

    I like this weblog so much, saved to my bookmarks.

  44. xiaorr456 Says:

    I recently came accross your website and possess been reading along. I was thinking I might leave my very first comment. Nice blog. Ill keep visiting this site very frequently. Thanks

  45. プロペシア通販 Says:

    フィンペシア通販
    フィンペシア通販
    フィンペシア通販

    フィンペシア通販
    フィンペシア通販
    フィンペシア通販
    フィンペシア通販

    プロペシア最安値
    プロペシア通販
    プロペシア通販
    プロペシア価格

    プロペシア価格
    プロペシア価格
    プロペシア 効果
    プロペシア通販

    プロペシア通販
    フィンペシア通販
    プロペシア購入
    プロペシア通販価格

    Thank you. Very helpful.924
    プロペシア副作用
    プロペシア通販
    ロゲイン通販

  46. プロペシア通販 Says:

    ミノキシジルタブレット
    ミノキシジルタブレット通販
    ミノキシジル
    ミノキシジルタブレット通販

    濃密育毛剤BUBKA(ブブカ)効果
    濃密育毛剤BUBKA(ブブカ)体験談
    育毛剤BUBKA(ブブカ)
    ロゲインの口コミ評判

    ロゲイン通販業者比較
    プロペシア通販
    プロペシア通販
    プロペシア通販

    プロペシア薬価
    プロペシア飲み方
    プロペシア耐性
    プロペシア副作用

    ロゲイン 通販
    ロゲイン通販業者比較
    フィンペシア
    フィンペシア通販

    育毛剤
    育毛剤 比較

    発毛剤

    カークランド通販
    カークランド
    カークランドの通販
    フィンカー通販

    フィンカー通販
    ゼニカル 購入
    ゼニカル 最安値
    ゼニカル購入

    ED治療薬 比較
    ED治療薬 通販
    レスベラトロール サプリメント
    レスベラトロール 効果

    658
    アサイー の効果
    アサイー スーパーフルーツ
    アサイージュース
    育毛サプリ ファーミア・ヘアー

    0066
    ほうれい線対策 豊麗 
    ほうれい線 消す
    性交痛 原因
    性交痛 ゼリー

  47. KAREEM MOERY Says:

    A powerful share, I simply given this onto a colleague who was doing slightly analysis on this. And he in actual fact bought me breakfast as a result of I found it for him.. smile. So let me reword that: Thnx for the deal with! But yeah Thnkx for spending the time to debate this, I feel strongly about it and love reading more on this topic. If attainable, as you grow to be expertise, would you mind updating your blog with more details? It’s extremely useful for me. Large thumb up for this blog put up!

  48. indboforsikring Says:

    A covey of parents are writing on the similar position owing to this one, however unconditional is completed in a special passage here. aliment corporal up.

  49. » MIT CSAIL Project Could Transform Robotic Design and Production Says:

    [...] The project could have far reaching implications for a variety of fields. The Massachusetts Institute of Technology (MIT) is leading an ambitious new project to reinvent how robots are designed and produced. Funded by a $10 million grant from the National Science Foundation (NSF), the project will aim to develop a desktop technology that would make it possible for the average person to design, customize and print a specialized robot in a matter of hours. “This research envisions a whole new way of thinking about the design and manufacturing of robots, and could have a profound impact on society,” said MIT Professor Daniela Rus, leader of the project and a principal investigator at the MIT Computer Science and Artificial Intelligence Lab (CSAIL). “We believe that it has the potential to transform manufacturing and to democratize access to robots.” “Our goal is to develop technology that enables anyone to manufacture their own customized robot. This is truly a game changer,” said Professor Vijay Kumar, who is leading the team from the University of Pennsylvania. “It could allow for the rapid design and manufacture of customized goods, and change the way we teach science and technology in high schools.” The five-year project, called “An Expedition in Computing for Compiling Printable Programmable Machines,” brings together a team of researchers from MIT, the University of Pennsylvania and Harvard University, and is funded as part of the NSF’s “Expeditions in Computing” program. It currently takes years to produce, program and design a functioning robot, and is an extremely expensive process, involving hardware and software design, machine learning and vision, and advanced programming techniques. The new project would automate the process of producing functional 3-D devices and allow individuals to design and build functional robots from materials as easily accessible as a sheet of paper. “Our vision is to develop an end-to-end process; specifically, a compiler for building physical machines that starts with a high level of specification of function, and delivers a programmable machine for that function using simple printing processes,” said Rus. Researchers hope to create a platform that would allow an individual to identify a household problem that needs assistance; then head to a local printing store to select a blueprint, from a library of robotic designs; and then customize an easy-to-use robotic device that could solve the problem. Within 24 hours, the robot would be printed, assembled, fully programmed and ready for action. Read more . . . via MIT ᔥ Bookmark this page for "Robotic Design" and check back regularly as these articles update on a very frequent basis. The view is set to "news". Try clicking on "video" and "2" for more articles. > The project could have far reaching implications for a variety of fields. The Massachusetts Institu… [...]

  50. » MIT CSAIL Project Could Transform Robotic Design and Production Says:

    [...] The project could have far reaching implications for a variety of fields. The Massachusetts Institute of Technology (MIT) is leading an ambitious new project to reinvent how robots are designed and produced. Funded by a $10 million grant from the National Science Foundation (NSF), the project will aim to develop a desktop technology that would make it possible for the average person to design, customize and print a specialized robot in a matter of hours. “This research envisions a whole new way of thinking about the design and manufacturing of robots, and could have a profound impact on society,” said MIT Professor Daniela Rus, leader of the project and a principal investigator at the MIT Computer Science and Artificial Intelligence Lab (CSAIL). “We believe that it has the potential to transform manufacturing and to democratize access to robots.” “Our goal is to develop technology that enables anyone to manufacture their own customized robot. This is truly a game changer,” said Professor Vijay Kumar, who is leading the team from the University of Pennsylvania. “It could allow for the rapid design and manufacture of customized goods, and change the way we teach science and technology in high schools.” The five-year project, called “An Expedition in Computing for Compiling Printable Programmable Machines,” brings together a team of researchers from MIT, the University of Pennsylvania and Harvard University, and is funded as part of the NSF’s “Expeditions in Computing” program. It currently takes years to produce, program and design a functioning robot, and is an extremely expensive process, involving hardware and software design, machine learning and vision, and advanced programming techniques. The new project would automate the process of producing functional 3-D devices and allow individuals to design and build functional robots from materials as easily accessible as a sheet of paper. “Our vision is to develop an end-to-end process; specifically, a compiler for building physical machines that starts with a high level of specification of function, and delivers a programmable machine for that function using simple printing processes,” said Rus. Researchers hope to create a platform that would allow an individual to identify a household problem that needs assistance; then head to a local printing store to select a blueprint, from a library of robotic designs; and then customize an easy-to-use robotic device that could solve the problem. Within 24 hours, the robot would be printed, assembled, fully programmed and ready for action. Read more . . . via MIT ᔥ Bookmark this page for "Robotic Design" and check back regularly as these articles update on a very frequent basis. The view is set to "news". Try clicking on "video" and "2" for more articles. > The project could have far reaching implications for a variety of fields. The Massachusetts Institu… [...]

Leave a Reply

blog comments powered by Disqus