SlideShare a Scribd company logo
1 of 49
Behaviors in Silverlight & WPF XAML Solutionsfor  XAML Problems Joe Gershgorin http://twitter.com/ThatJoeG joe@bitspy.com
Demo Attached Behavior
Dependency Properties Properties on steroids Developer usually creates these when creating custom controls, behaviors, and user controls. ,[object Object]
Default values
Property Inheritance
Data Binding
Animation
Property Change Notification
Styling
In WPF Only:
Property Invalidation
Dependent value coercion,[object Object]
Dependency Properties Properties on steroids private static void OnHighlightBorderBrushPropertyChanged (DependencyObject d, DependencyPropertyChangedEventArgs e) { varmyClass = (MyClass)d; }
Dependency Properties Properties on steroids Unless you enjoy punishment, once you understand dependency properties use a code generator to create them. For WPF I use Dr. WPF Code Snippets available from here: http://drwpf.com/Blog/Default.aspx?tabid=36&EntryID=22
Dependency Properties Properties on steroids Other code generators include Resharper templates and snippets for Silverlight from the Silverlight Contrib Project http://silverlightcontrib.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=21368 ReSharper Live Templates     * SLDependProp - Generates a Dependency Property without a change callback     * SLDependPropChanged - Generates a Dependency Property with a change callback     * SLDependPropAttached - Generates an Attached Dependency Property     * SLInlineSBCompletedHandler - Generates an inline Storyboard Completed handler     * SLRoutedEvent - Generates a RoutedEvent
Dependency Properties Properties on steroids ReSharper File Templates     * ClientAccessPolicy.xml File Template     * CrossDomain.xml File Template     * Silverlight Value Converter Template     * Silverlight Panel Visual Studio Code Snippets     * sldp - Generates a Dependency Property without a change callback     * sldpc - Generates a Dependency Property with a change callback     * sldpa - Generates an Attached Dependency Property     * slevent - Generates a RoutedEvent     * slsbc - Generates an inline Storyboard Completed handler     * slpanel - Generates a Panel     * slrss - A super basic collection class that loads an RSS feed     * slvc - Silverlight Value Converter Template
Dependency Properties Properties on steroids KirupaChinnathambi’s Dependency Property Generator http://www.kirupa.com/blend_silverlight/dependency_property_generator.htm
Attached Properties Class instance to acts on another class instance ,[object Object]
Defined with a RegisterAttached and setter/getter syntax different from a depedency property.,[object Object]
Demo Blend Behavior
What is a Behavior? Which of the following describes a  behavior? ,[object Object]
Attached property
Static class that acts on other classes
Classes instance that acts on other class instances
XAML Addon
Drag & Drop Functionality through Blend,[object Object]
Native support in Blend to detect behaviors in a open project, allow you to drag and drop a behavior onto an element on the design surface. Behaviors can be found in the asset panel and properties of the behavior can be set in the Blend properties pane.
Microsoft provided API for building Behaviors in both Silverlight  & WPF.
Expression Gallery website to share and rate behaviors:http://gallery.expression.microsoft.com/en-us/site/search?f[0].Type=RootCategory&f[0].Value=behaviors&f[0].Text=Behaviors
Expression Blend 3 - Behaviors ,[object Object],rogram Filesicrosoft SDKsxpressionlend 3nteractivityibraries..System.Windows.Interactivity.dll ,[object Object], http://www.microsoft.com/downloads/details.aspx?FamilyID=F1AE9A30-4928-411D-970B-E682AB179E17&displaylang=en
Expression Blend 3 - Behaviors ,[object Object]
Adds new item templates in both Visual Studio & Blend to create Actions, Triggers & Behaviors
Sketch Flow Player
More powerful VSM engine, allowing for fluid transitions,[object Object]
Abstract Classes Provided to aid in creating behaviorsBehavior (<T>) ,[object Object]
Overrides
OnAttached
Good place to write init code, and event subscriptions
OnDeataching
Clean up resources, unsubscribe to events here
Methods
Attach & Detach
Can be used by code behind to attach/detach the behavior to a XAML element.,[object Object]
Abstract Classes Provided to aid in creating behaviorsBehavior (<T>) ,[object Object]
AssociatedObject
The object you’re attached to (Grid, Button, etc..),[object Object]
Expression Blend 3 - Behaviors ,[object Object]
Triggers & Actions
TriggerBase (,[object Object]

More Related Content

Recently uploaded

The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
Alexander Litvinenko
 

Recently uploaded (20)

Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptx
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Behaviors In WPF & Silverlight Silicon Valley Code Camp 2009

Editor's Notes

  1. value expressions, property invalidation and dependent-value coercion, http://drwpf.com/Blog/Default.aspx?tabid=36&EntryID=22
  2. Attached Properties Overviewhttp://msdn.microsoft.com/en-us/library/ms749011.aspx
  3. Attached Properties OverviewGrid.SetValuehttp://msdn.microsoft.com/en-us/library/ms749011.aspx
  4. C:Program Files (x86)Microsoft SDKsExpressionBlend 3InteractivityLibraries
  5. Microsoft Expression Blend 3 introduces behaviors, which are reusable pieces of packaged code that can be dragged onto any object, and then fine-tuned by changing their properties. Behaviors allow you to add interactivity to your applications without having to write any code. The Behavior API consists of three core classes: Trigger, Action and Behavior. This SDK explores how to write each of these components, and contains a few code samples to help you get started. Programming reference topics are provided for both Windows Presentation Foundation (WPF) and Microsoft Silverlight. For more how-to and overview information about behaviors in Expression Blend, see the Expression Blend User Guide, available when you install Expression Blend 3 + SketchFlow.The Expression Blend 3 SDK also contains the following redistributable components: SketchFlow PlayerCustom VSM for Fluid LayoutFont Embedding enhancementsThe Expression Blend 3 SDK is required to view an Expression Blend 3 project that uses any of these components if Expression Blend 3 is not installed.