14. 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
15. 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
16. 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
27. 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.
29. 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
30.
31.
32. Adds new item templates in both Visual Studio & Blend to create Actions, Triggers & Behaviors
103. Explore Blend Sample Behaviors Library of useful sample behaviors and effects http://expressionblend.codeplex.com/ rogram Filesicrosoft Expressionlend 3 Samples..xpression.Samples.Interactivity.dll rogram Filesicrosoft Expressionlend 3 Samples..icrosoft.Expression.Interactions.dll rogram Filesicrosoft Expressionlend 3 Samples..xpression.Samples.Shaders.dll Media Behaviors PlayMedia Action to play a media element. PauseMedia Action to pause a media element. TogglePlayPauseMedia Toggles a media element between play and pause mode. RewindMedia Action to rewind a media element. StopMedia Action to stop a media element.
104. Explore Blend Sample Behaviors Library of useful sample behaviors and effects Triggers MouseGestureTrigger Triggers an event when the user makes a mouse gesture on the element. The gesture can be defined in Blend's property inspector. MouseEventTrigger Allows triggering from complex mouse events such as double click or mouse clicks with modifier keys. StateChangedTrigger Fires when a state is changing (or has changed). Can trigger when a specific state has changed or when any state has changed.
105. Explore Blend Sample Behaviors Library of useful sample behaviors and effects Data Behaviors CallDataMethod An action which calls a method on the data context. Good for tying an event in your View to do something in the ViewModel for MVVM styled applications. InvokeDataCommand Example of invoking the CheckOut command when a button is clicked: #An example of calling the Remove method when a button is clicked: <i:EventTrigger EventName="Click"> <si:CallDataMethod Target="{Binding ShoppingCart.CurrentItem}" Method="Remove"/> </i:EventTrigger> #An example of calling the Remove method when a button is clicked: <i:EventTrigger EventName="Click"> <si:InvokeDataCommand Command="{Binding ShoppingCart.CheckOutCommand}"/> </i:EventTrigger>
106. Explore Blend Sample Behaviors Library of useful sample behaviors and effects Data Behaviors DataEventTrigger Triggers an action when an event on the data context is raised (as opposed to EventTrigger’s routed event on a UI element). SetDataProperty Action which sets a property when executed. It can either set the value directly, or increment the value by the specified amount. #XAML syntax to play a sound every time the MessageSent event is raised from the User object: <si:DataEventTrigger Source="{Binding User}" EventName="MessageSent"> <im:PlaySoundAction Source="Bell.wma"/> </si:DataEventTrigger> #XAML syntax to increment a value when a button is clicked: <i:EventTrigger EventName="Click"> <si:SetDataProperty Binding='{Binding ItemCount, Mode=TwoWay}‘ Increment='True' Value='1'/> </i:EventTrigger>
107. Explore Blend Sample Behaviors Library of useful sample behaviors and effects Data Behaviors DataStateBehavior Switches between two VSM states depending on the value of a binding. This is a convenient shorthand for two DataTriggers with GoToState actions. With Blend 3’s support for VSM in DataTemplates this makes it easy to have states for data. #XAML syntax for a DataTemplate with VSM and a DataStateBehavior to switch between the two states depending on whether the user is logged in or not: <DataTemplate x:Key='User'> <Grid> <VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups> <i:Interaction.Behaviors> <si:DataStateBehavior Binding='{Binding IsLoggedIn}' Value='True‘ TrueState='LoggedInState' FalseState='LoggedOutState'/> </i:Interaction.Behaviors> </Grid> </DataTemplate>
108. Explore Blend Sample Behaviors Library of useful sample behaviors and effects Data Behaviors DataStateSwitchBehavior Similar to the DataStateBehavior, allows switching between more than two states- useful for encapsulating more conditional state logic. FluidBindProperty Behavior which acts as a proxy for databound properties in order to animate the changing of the value. #XAML syntax of binding the height of a rectangle to a property and having it grow with an elastic ease: <si:FluidBindProperty Binding='{Binding Population}' PropertyName='Height' Duration='0:0:0.1'> <si:FluidBindProperty.Ease> <ElasticEaseEasingMode="EaseOut"/> </si:FluidBindProperty.Ease> </si:FluidBindProperty>
109. Explore Blend Sample Behaviors Library of useful sample behaviors and effects Data Behaviors PropertyChangedTrigger Fires whenever a property changes, regardless of the new value. <si:PropertyChangedTrigger Binding="{Binding IsActive}"> <si:PlayMedia/> </si:PropertyChangedTrigger>
110. Explore Blend Sample Behaviors Library of useful sample behaviors and effects Additional Behaviors CallMethod ClippingBehavior Provides a rounded rectangular clipping that scales with the element. Useful since Silverlight and WPF clipping geometries don't scale with objects. GoToNextState Go to the next state in a VisualStateManager. Useful for quickly navigating between various states. GoToPreviousState Go to the previous state in a VisualStateManager. Useful for quickly navigating between various states. SetProperty Similar to ChangePropertyAction but allows incrementing as well as setting. ShowMessageBox Displays a standard message box to the user
111. Explore Blend Sample Behaviors Library of useful sample behaviors and effects Prototyping Behaviors ListBoxAddOne Action which duplicates a random item in the ItemsSource collection of a ListBox. Useful for SketchFlow prototypes where you want to show adding a new item. ListBoxRemoveOne Action which removes a random item in the ItemsSource collection of a ListBox. Useful for SketchFlow prototypes to simulate removing an item. ListBoxRemoveThisItem Action for use inside of a ListBoxItem which will remove the item from the data collection of the owning ListBox. Effects This contains many of the effects from the WPF FX (http://www.codeplex.com/fx) project packaged up with full design-time support inside of Blend.
112.
113. Identical API. Behaviors, Triggers, TriggerActions & TargetedTriggerActions abstract classes are available in both WPF in Silverlight System.Windows.Interactivity assembly.
126. Adds Binding support to Non FrameworkElement object properties such as the Angle property of a Rotate RenderTransform.<TextBoxRenderTransformOrigin="0.5,0.5“ Text="Hello Universe!" binders:SurrogateBind.Value="{Binding Path=MoreValues.Heading}" binders:SurrogateBind.Target="RenderTransform.Children.Item[1].Angle" > <TextBox.RenderTransform><TransformGroup><ScaleTransform /> <RotateTransform /></TransformGroup></TextBox.RenderTransform> </TextBox>
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.