How do I trigger an animation when the data in the control is changed?

Animations can be applied to the objects in WPF application when the data in the control changes using the DataTriggers. The following lines of code is used to apply animations using a DataTrigger [XAML] <TextBlock Text='WPF Application' Name='tb1' Foreground='Blue' FontSize='28' TextAlignment='Center' Height='50' VerticalAlignment='Top'> <TextBlock.Style> <Style> <Style.Triggers> <DataTrigger Binding='{Binding ElementName=cb1,Path=IsChecked}' Value='true'> <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty='Opacity' From='0' To='1' Duration='0:0:1' AutoReverse='True' RepeatBehavior='Forever' /> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> <DataTrigger.ExitActions> <BeginStoryboard> <Storyboard FillBehavior='Stop'> <DoubleAnimation Storyboard.TargetProperty='Opacity' To='1' Duration='0:0:1' /> </Storyboard> </BeginStoryboard> </DataTrigger.ExitActions> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> <CheckBox Name='cb1' Content='Show Animation' IsChecked='True' Height='30' HorizontalAlignment='Center' />

How can I bind a method and pass a parameter to the method ?

As with support for parameterized constructor, this is most useful for existing classes that are not databinding-friendly and can’t be changed. For your own types, you might as well expose potential datasources as properties. But note that the photos collection exposed a method call ‘GetFolderName’, that returned a string representing the folder containing all the current items. You could expose this method as a datasource as follows. [XAML} <ObjctDataProvider x:Key='dataProvider' ObjectType='{x:Type Local:Photos}' MethodName='GetFolderName'/> If the parameters need to be passed to the method, you can use ObjectDataProvider’s ‘MethodParameters’ property ( which works just like it’s ConstructorParameter property). To Bind this method, simply bind it to the entire ObjectDataProvider. [XAML] <TextBlock Text='{Binding source={StaticResource dataProvider}}'/> Specifying the path in this case would apply to the instance returned by the method.

How do I include a delay only for the first tooltip and not for subsequent tooltips in my app?

The trick is to use the InitialShowDelay and BetweenShowDelay property appropriately as shown below in all your tooltips: [XAML] <Ellipse Height='25' Width='50' Fill='Gray' HorizontalAlignment='Left' ToolTipService.InitialShowDelay='1000' ToolTipService.ShowDuration='7000' ToolTipService.BetweenShowDelay='2000'> <Ellipse.ToolTip> <ToolTip Placement='Right' PlacementRectangle='50,0,0,0' HorizontalOffset='10' VerticalOffset='20' HasDropShadow='false' Opened='whenToolTipOpens' Closed='whenToolTipCloses' > <BulletDecorator> <BulletDecorator.Bullet> <Ellipse Height='10' Width='20' Fill='Blue'/> </BulletDecorator.Bullet> <TextBlock>Uses the ToolTip Class

How do I use the TooltipService class?

The following example shows how to use the ‘ToolTipService’ properties to specify the position of a tooltip among other things. This also shows how the tooltip look and feel can be customized with any content. [XAML] <Ellipse Height='25' Width='50' Fill='Gray' HorizontalAlignment='Left' ToolTipService.InitialShowDelay='1000' ToolTipService.ShowDuration='7000' ToolTipService.BetweenShowDelay='2000' ToolTipService.Placement='Right' ToolTipService.PlacementRectangle='50,0,0,0' ToolTipService.HorizontalOffset='10' ToolTipService.VerticalOffset='20' ToolTipService.HasDropShadow='false' ToolTipService.ShowOnDisabled='true' ToolTipService.IsEnabled='true' ToolTipOpening='whenToolTipOpens' ToolTipClosing='whenToolTipCloses' > <Ellipse.ToolTip> <BulletDecorator> <BulletDecorator.Bullet> <Ellipse Height='10' Width='20' Fill='Blue'/> </BulletDecorator.Bullet> <TextBlock>Uses the ToolTipService class</TextBlock> </BulletDecorator> </Ellipse.ToolTip> </Ellipse>

How can I save the contents of a FlowDocumentReader as an XAML file ?

This example demonstrates how to save the contents of a FlowDocumentReader (represented by the ‘Document’ property) as an XAML file. [XAML] <FlowDocumentReader Name='flowDocRdr' IsFindEnabled='True' IsPrintEnabled='True' MinZoom='50' MaxZoom='1000' Zoom='120' ZoomIncrement='5' /> To save the contents of the FlowDocumentReader to a file, open or create the file stream and use the ‘Save()’ method provided by the ‘XAMLWriter’ class to write the FlowDocument to the file stream. [C#] void SaveFlowDocumentReaderWithXAMLFile(string fileName) { // Open or create the output file. FileStream xamlFile = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite); // Save the contents of the FlowDocumentReader to the file stream that was just opened. XamlWriter.Save(flowDocRdr.Document, xamlFile); xamlFile.Close(); }