<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>IRhetoric - Karsten Januszewski   : Windows Presentation Foundation (Avalon)</title><link>http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx</link><description>Tags: Windows Presentation Foundation (Avalon)</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>COLLABORATING ON CREATING ANIMATIONS IN WPF AND BLEND: POSSIBILITIES AND LIMITATIONS</title><link>http://blogs.msdn.com/karstenj/archive/2007/06/20/collaborating-on-creating-animations-in-wpf-and-blend-possibilities-and-limitations.aspx</link><pubDate>Thu, 21 Jun 2007 02:16:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3433330</guid><dc:creator>karstenj</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/3433330.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=3433330</wfw:commentRss><description>&lt;p&gt;One area that is currently top of mind for me is designer and developer collaboration with WPF and Expression Blend, in particular around animation.&amp;nbsp; I'd like to start documenting some techniques and outlining things that can and can't be done.&amp;nbsp;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Before diving in, let's quickly review the animation system in WPF.&amp;nbsp; The two ways to do animation in WPF is either declaratively (XAML) or procedurally (code).&amp;nbsp;&amp;nbsp;&amp;nbsp;If you use Expression Blend to create your animations, you will be in effect using the declarative (XAML) method.&amp;nbsp; What gets slightly confusing is that the two methods, declarative and procedural,&amp;nbsp;are not entirely in parallel.&amp;nbsp; For example, the only way to begin an animation declaratively (XAML) is through the &amp;lt;&lt;strong&gt;BeginStoryboard&lt;/strong&gt;&amp;gt; tag.&amp;nbsp; However, the equivalent call in code is to call the &lt;strong&gt;Begin&lt;/strong&gt; method off a &lt;strong&gt;UIElement&lt;/strong&gt; and&amp;nbsp; passing it the storyboard to fire.&amp;nbsp; The other option is to call the &lt;strong&gt;Begin&lt;/strong&gt; method from a storyboard itself, passing it the &lt;strong&gt;UIElement&lt;/strong&gt; to which the storyboard should be applied. And, in code, you can trigger animations that don't even have storyboards using&amp;nbsp;the &lt;strong&gt;ApplyAnimationClock&lt;/strong&gt; or &lt;strong&gt;BeginAnimation&lt;/strong&gt; directly off a &lt;strong&gt;UIElement&lt;/strong&gt;.&amp;nbsp; (More on this later if you're confused. The syntax is, like much of WPF, a little tricky.)&lt;/p&gt; &lt;p&gt;But all of the above -- and &lt;a href="http://msdn2.microsoft.com/en-us/library/ms752312.aspx"&gt;much of the SDK documentation on animation&lt;/a&gt; -- assumes that you have chosen either one or the other.&amp;nbsp; What happens if you want to mix and match these two methods?&amp;nbsp; This particularly comes into play if you are working on a project where animations get created in Blend but then need to be manipulated, triggered and recontextualized from code.&amp;nbsp; And it potentially gets more tricky if you have multiple people working on the project, the classic scenario being one person who creates the animations in Blend and another who works with those animations in code. &lt;/p&gt; &lt;p&gt;So, let's look at the possibilities:&lt;/p&gt; &lt;p&gt;&lt;font size="4"&gt;1. How to&amp;nbsp;trigger a storyboard from code that was created in Blend.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Let's say we have an animation in Blend to do&amp;nbsp;an opacity fade on an&amp;nbsp;image.&amp;nbsp; Assuming it was created&amp;nbsp;&amp;nbsp;by creating a new timeline and leave the "Create as a resource" checkbox checked, we can get at it from code pretty easily.Simply grab the storyboard from the resources, cast it appropriately&amp;nbsp;and begin it.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;Storyboard s = (Storyboard) this.FindResource("FadeIn");&lt;br&gt;this.BeginStoryboard(s);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Now, the reason this works is that the storyboard itself contains information about the name of the object that it wants to animate.&amp;nbsp; If you look at the storyboard &lt;a href="http://winfx.members.winisp.net/files/animationcollab.zip"&gt;in the sample code I posted&lt;/a&gt;, it sets the &lt;strong&gt;Storyboard.TargetName&lt;/strong&gt; value explicitly to the name "image".&amp;nbsp; Thus, when the storyboard is called from the page itself via &lt;strong&gt;BeginStoryboard&lt;/strong&gt;, it is able to find the element named image and run the animations. But what happens if we want to generically apply that animation that was created in Blend to other elements? &lt;/p&gt; &lt;p&gt;&lt;font size="4"&gt;2. How to trigger a storyboard from code and apply it to another UI element&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Well, to accomplish this task, we need to start hacking XAML.&amp;nbsp; If this scares you, don't read on.&amp;nbsp; But the fact is that XAML generated from Blend sometimes needs a little love. So, in this case, we are going to copy that storyboard.&amp;nbsp; We can't do that without jumping into the XAML and manually coping the entire &amp;lt;Storyboard&amp;gt; and giving it a new x:Key. Once we've done that, we have manually remove every instance where &lt;strong&gt;Storyboard.TargetName&lt;/strong&gt; is set.&amp;nbsp; Literally, remove the entire&amp;nbsp;attribute. Now, we can apply this storyboard to any &lt;strong&gt;UIElement&lt;/strong&gt; and not just images.&amp;nbsp;&amp;nbsp;In this case, we call the &lt;strong&gt;Begin&lt;/strong&gt; method from the storyboard itself, passing the element we want&amp;nbsp;the storyboard to be applied to.&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;Storyboard s = (Storyboard)this.FindResource("FadeIn2");&lt;br&gt;s.Begin(textBlock);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;The thing to watch out for with this technique is to make sure you call the storyboard on an element that in fact has all the properties referenced in the storyboard.&amp;nbsp; Otherwise, you'll get a runtime exception that says something like:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;Additional information: '[Unknown]' property does not point to a DependencyObject in path '(0).(1).[0].(2)'.&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Which is saying that the animation could find the property that it was told to animate.&amp;nbsp; A place where this can get you is if you are doing any Transform animations, such as Scale, Translate, Rotate or Skew.&amp;nbsp; By default, when you add an element to Blend, it does not create a TransformGroup for it. For example, go to Blend, add a &lt;strong&gt;Rectangle&lt;/strong&gt; to the stage and see what it creates in XAML. It won't have a &lt;strong&gt;RenderTransform&lt;/strong&gt;.&amp;nbsp; Now, go change its scale to 2 and then change it back to 1.&amp;nbsp; Now look at its XAML: a RenderTransform has been permanently added to it as a child which doesn't do anything! Blend counts on that &lt;strong&gt;TransformGroup&lt;/strong&gt; for doing its animations, in that exact order (Scale, Skew, Rotate, Translate).&amp;nbsp; So, if you've created an animation that does a transform and you want to apply it to some other element, be sure that the element has a &lt;strong&gt;TransformGroup&lt;/strong&gt; with the four transforms.&lt;/p&gt; &lt;p&gt;&lt;font size="4"&gt;3. How to tweak an animation created in Blend on the fly in code&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Let's say there's an animation created in Blend that you want to use, but you want to actually modify it with some dynamic values at runtime, maybe adding more animation.&amp;nbsp; First, you grab the storyboard and clone it so you have a new instance to party on. Then, you create your animation in code -- that's where you could insert dynamic variables.&amp;nbsp; Finally, you have to create a property path to the value you want animated.&amp;nbsp; The syntax is a little goofy, but once you crack its code as far as a path (&lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.propertypath.path.aspx"&gt;good doc here&lt;/a&gt;) you'll be off and running.&amp;nbsp; Here's the code I used to add a scale animation on the fly:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;Storyboard s = ((Storyboard)this.FindResource("FadeIn2")).Clone();&lt;br&gt;DoubleAnimation da = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1), FillBehavior.HoldEnd);&lt;br&gt;Storyboard.SetTargetProperty(da, new PropertyPath("(0).(1).[0].(2)", UIElement.RenderTransformProperty,&lt;br&gt;TransformGroup.ChildrenProperty,&lt;br&gt;ScaleTransform.ScaleXProperty));&lt;br&gt;s.Children.Add(da);&lt;br&gt;s.Begin(rectangle);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;You could use a similar technique to crack into the storyboard, grab an animation that was created in XAML and tweak it.&amp;nbsp; So for example, we could grab the animation from the storyboard and change its begin time like this:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;DoubleAnimationUsingKeyFrames d = (DoubleAnimationUsingKeyFrames)s.Children[0];&lt;br&gt;d.BeginTime = TimeSpan.FromSeconds(.5);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="4"&gt;4. How to crack into an animation that is part of a DataTemplate&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Doh! You can't!&amp;nbsp; I tried every workaround I could, but once a &lt;strong&gt;ContentTemplate&lt;/strong&gt; gets loaded, it is in the WPF terminology "Sealed" and I've never seen a way to make it unsealed, even before it is added to the visual tree.&amp;nbsp; Bummer.&lt;/p&gt; &lt;p&gt;**********************************&lt;/p&gt; &lt;p&gt;So where are we?&amp;nbsp; We've&amp;nbsp;learned&amp;nbsp;some techniques such that a design technologist or interactive designer or diviner (or whatever they are called) can work in Blend, creating subtle and great animations and then, if there are scenarios where the developer or integrator or diviner (or whatever they are called) needs to start that animation, reuse that animation or tweak that animation on the fly, they can. Go WPF!&lt;/p&gt; &lt;p&gt;&lt;a href="http://winfx.members.winisp.net/files/animationcollab.zip"&gt;Download the code&lt;/a&gt;&lt;/p&gt;&lt;img src="http://winfx.members.winisp.net/files/snowboard.jpg"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3433330" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Expression+Blend/default.aspx">Expression Blend</category></item><item><title>CREATING A .NET TWITTER API in 4.5 SECONDS</title><link>http://blogs.msdn.com/karstenj/archive/2007/06/08/creating-a-net-twitter-api-in-4-5-seconds.aspx</link><pubDate>Sat, 09 Jun 2007 00:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3168876</guid><dc:creator>karstenj</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/3168876.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=3168876</wfw:commentRss><description>&lt;P&gt;I've been meaning to document how I wrapped the Twitter API ... in 4.5 seconds.&amp;nbsp;&amp;nbsp; There is a&amp;nbsp;very powerful feature in .NET is a tool in the sdk called &lt;STRONG&gt;xsd.exe&lt;/STRONG&gt;.&amp;nbsp; Darren David actually has &lt;A href="http://blog.lookorfeel.com/index.php/2007/05/02/the-net-xml-schema-definition-tool-or-how-i-learned-to-stop-parsing-and-love-the-dom-part-1/" mce_href="http://blog.lookorfeel.com/index.php/2007/05/02/the-net-xml-schema-definition-tool-or-how-i-learned-to-stop-parsing-and-love-the-dom-part-1/"&gt;a fabulous post&lt;/A&gt; on&amp;nbsp;exactly the power of this tool: never touch a DOM&amp;nbsp;or XPATH again!&amp;nbsp; &amp;nbsp;His post explains what is happening under the hood with xsd.exe quite nicely.&amp;nbsp;I'd definitely recommend reading his post.&amp;nbsp; I figured it might be interesting for folks to see&amp;nbsp;the exact steps I took to wrap the Twitter API:&lt;/P&gt;
&lt;P&gt;1. Grab an instance of the public timeline from Twitter and pass that to xsd.exe to infer a schema as follows: &lt;STRONG&gt;xsd&lt;/STRONG&gt; &lt;A title=http://twitter.com/statuses/public_timeline.xml href="http://twitter.com/statuses/public_timeline.xml" mce_href="http://twitter.com/statuses/public_timeline.xml"&gt;http://twitter.com/statuses/public_timeline.xml&lt;/A&gt;&amp;nbsp;which creates public_timeline.xsd&lt;/P&gt;
&lt;P&gt;3. Use the inferred schema to generate classes: &lt;STRONG&gt;xsd&lt;/STRONG&gt; public_timeline.xsd&lt;/P&gt;
&lt;P&gt;4. Walla!&amp;nbsp; We now have a class to party on called public_timeline.cs&lt;/P&gt;
&lt;P&gt;5. To instantiate the class with live data, it is as simple as the following:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(statuses));&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;statuses s = serializer.Deserialize(new System.Xml.XmlTextReader("&lt;/STRONG&gt;&lt;/FONT&gt;&lt;A href="http://twitter.com/statuses/public_timeline.xml%22))" mce_href='http://twitter.com/statuses/public_timeline.xml"))'&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;http://twitter.com/statuses/public_timeline.xml"))&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt; as statuses;&lt;/STRONG&gt;&lt;/FONT&gt; 
&lt;P&gt;And there you have it.&amp;nbsp; No DOM, no XPATH, no RegEx.&amp;nbsp; Now, if we want to take this wrapper to the next level, there are a few things we can do.&amp;nbsp; First, you will notice that Twitter returns the data as a string.&amp;nbsp; That's kind of a bummer; it would be nice to have it as a strongly typed &lt;STRONG&gt;DateTime&lt;/STRONG&gt;.&amp;nbsp; Here's the line of code to do that: 
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;DateTime date = DateTime.ParseExact(s.created_at, "ddd MMM dd HH:mm:ss zzzzz yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);&lt;/STRONG&gt;&lt;/FONT&gt; 
&lt;P&gt;Another thing that you'll need to do is authenticate when you contact Twitter if you want data other than the public timeline.&amp;nbsp; Here's how to do that: 
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;using (WebClient client = new WebClient())&lt;BR&gt;{&lt;BR&gt;client.Credentials = new NetworkCredential(TWITTER_USERNAME, TWITTER_PASSWORD);&lt;BR&gt;statuses s = serializer.Deserialize(client.OpenRead(TWITTER_URL)) as statuses;&lt;BR&gt;}&lt;/STRONG&gt;&lt;/FONT&gt; 
&lt;P&gt;Of course, the TWITTER variables need to be set with the username, password and particular URL to the Twitter feed you are looking for.&amp;nbsp; 
&lt;P&gt;Another thing to think about doing is making the calls to Twitter on a different thread.&amp;nbsp; My recommendation for doing that is to implement &lt;A href="http://blogs.msdn.com/dancre/archive/2006/10/11/datamodel-view-viewmodel-pattern-series.aspx" mce_href="http://blogs.msdn.com/dancre/archive/2006/10/11/datamodel-view-viewmodel-pattern-series.aspx"&gt;Dan Crevier's Data-View-View Model&lt;/A&gt;.&amp;nbsp; This frees the UI thread from any calls to Twitter and provides a really nice model for marshalling data between the threads.&amp;nbsp; In fact, I did just this in my &lt;A href="http://winfx.members.winisp.net/blog/flitter.zip" mce_href="http://winfx.members.winisp.net/blog/flitter.zip"&gt;Flitter&lt;/A&gt; and &lt;A href="http://blogs.msdn.com/coding4fun/attachment/2854939.ashx" mce_href="http://blogs.msdn.com/coding4fun/attachment/2854939.ashx"&gt;Flitterbook&lt;/A&gt; implementations, which you can check out in the source code. 
&lt;P&gt;The final thing to think about, which I just recently implemented in some code I was working on, was to make the naming conventions look prettier.&amp;nbsp; Darren David alluded to this in his post but he's been so busy with the totally amazing &lt;A href="http://blog.lookorfeel.com/index.php/2007/06/04/hp-multi-touch-interactive-canvas-launched-at-d5/" mce_href="http://blog.lookorfeel.com/index.php/2007/06/04/hp-multi-touch-interactive-canvas-launched-at-d5/"&gt;HP Multi Touch kiosk he built&lt;/A&gt; (which you have to check out the videos for if you haven't yet) that he hasn't posted his part II.&amp;nbsp; But I imagine he's going to talk about using partial classes so as to make the class look prettier without touching the generated code.&amp;nbsp; This came in real handy with the Twitter API which generated some code with ugly array structures that I wasn't so keen on.&amp;nbsp;I also had a need to use&amp;nbsp;a kind of cool feature of WPF databinding&amp;nbsp;where I&amp;nbsp;wanted to reuse a datatemplate between two&amp;nbsp;different objects&amp;nbsp;(Twitter status and Facebook status) by just having them share names, such as AvatarURL, rather than create two templates that were fundamentally identitcal except for the data object.&amp;nbsp;As such, I created a partial class with a bunch of getters as follows: 
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;public partial class statusesStatus&lt;BR&gt;{&lt;BR&gt;public DateTime Date&lt;BR&gt;{&lt;BR&gt;get&lt;BR&gt;{&lt;BR&gt;return DateTime.ParseExact((string)this.created_at, "ddd MMM dd HH:mm:ss zzzzz yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);&lt;BR&gt;}&lt;BR&gt;} &lt;/STRONG&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;public string AvatarUrl&lt;BR&gt;{&lt;BR&gt;get&lt;BR&gt;{&lt;BR&gt;return this.user[0].profile_image_url;&lt;BR&gt;}&lt;BR&gt;} &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;public string Text&lt;BR&gt;{&lt;BR&gt;get&lt;BR&gt;{&lt;BR&gt;return this.text;&lt;BR&gt;}&lt;BR&gt;} &lt;/STRONG&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;public string UserName&lt;BR&gt;{&lt;BR&gt;get&lt;BR&gt;{&lt;BR&gt;return this.user[0].screen_name;&lt;BR&gt;}&lt;BR&gt;} &lt;/STRONG&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;public string Location&lt;BR&gt;{&lt;BR&gt;get&lt;BR&gt;{&lt;BR&gt;return this.user[0].location;&lt;BR&gt;}&lt;BR&gt;} &lt;/STRONG&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;} &lt;/STRONG&gt;&lt;/FONT&gt;
&lt;P&gt;Now I have a much prettier class without touching the generated code from xsd.exe.&amp;nbsp; Sorry for stealing Part II Darren. I couldn't&amp;nbsp;help myself, as I&amp;nbsp;have been&amp;nbsp;meaning to write this post for about 2 months!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3168876" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Twitter/default.aspx">Twitter</category></item><item><title>New Lab Posted: Creating 3D Content with Windows Presentation Foundation</title><link>http://blogs.msdn.com/karstenj/archive/2007/03/28/new-lab-posted-creating-3d-content-with-windows-presentation-foundation.aspx</link><pubDate>Wed, 28 Mar 2007 23:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1980187</guid><dc:creator>karstenj</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1980187.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1980187</wfw:commentRss><description>&lt;P&gt;I just posted a &lt;A class="" href="http://wpf.netfx3.com/files/folders/labs/entry9680.aspx" mce_href="http://wpf.netfx3.com/files/folders/labs/entry9680.aspx"&gt;new lab for learning how to use 3D&lt;/A&gt; in WPF.&amp;nbsp; This is a great lab that I would highly recommend if you are learning WPF 3D. It shows how to do dynamic animation of 3D content as well as how to do 2D on 3D using the &lt;A class="" href="http://www.codeplex.com/3DTools" mce_href="http://www.codeplex.com/3DTools"&gt;3DTools&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 425px; HEIGHT: 419px" height=419 src="http://inlinethumb49.webshots.com/4592/2918638560100818464S425x425Q85.jpg" width=425 mce_src="http://inlinethumb49.webshots.com/4592/2918638560100818464S425x425Q85.jpg"&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1980187" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category></item><item><title>North Face Case Study Published</title><link>http://blogs.msdn.com/karstenj/archive/2007/03/22/north-face-case-study-published.aspx</link><pubDate>Thu, 22 Mar 2007 22:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1932897</guid><dc:creator>karstenj</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1932897.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1932897</wfw:commentRss><description>&lt;P&gt;&lt;A class="" href="http://www.microsoft.com/casestudies/casestudy.aspx?casestudyid=201147" mce_href="http://www.microsoft.com/casestudies/casestudy.aspx?casestudyid=201147"&gt;A case study about the North Face Kiosk&lt;/A&gt; is now posted to the Microsoft Case Studies site.&amp;nbsp; This is a nice write up, showing how the technology solved business problems, and explaining the larger context of how the kiosk plays into The North Face's overall marketing and sales goals. There are quite a few nice quotes about WPF in there and a shout out to WCF as well.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 427px; HEIGHT: 343px" height=343 src="http://www.microsoft.com/casestudies/resources/Images/201147/figure1.jpg" width=427 mce_src="http://www.microsoft.com/casestudies/resources/Images/201147/figure1.jpg"&gt;&amp;nbsp; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1932897" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Inspired By Flash Math Creativity #2: WPF Planets</title><link>http://blogs.msdn.com/karstenj/archive/2007/02/23/inspired-by-flash-math-creativity-2-wpf-planets.aspx</link><pubDate>Sat, 24 Feb 2007 00:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1749785</guid><dc:creator>karstenj</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1749785.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1749785</wfw:commentRss><description>&lt;P&gt;My next inspiration from the algorithms introduced in &lt;A target=_blank href="http://www.friendsofed.com/fmc/FMCv2/FMC.html" mce_href="http://www.friendsofed.com/fmc/FMCv2/FMC.html"&gt;Flash Math Creativity&lt;/A&gt;&amp;nbsp;was based on the work of &lt;A target=_blank href="http://www.nooflat.nu/" mce_href="http://www.nooflat.nu/"&gt;Jamie MacDonald&lt;/A&gt;. In looking at his work,&amp;nbsp; I quickly realized that I was going to need to brush up on my trigonometry skills. This led me to another great Friend of Ed book, &lt;A target=_blank href="http://www.friendsofed.com/book.html?isbn=1590595181" mce_href="http://www.friendsofed.com/book.html?isbn=1590595181"&gt;Foundation ActionScript Animation: Making Things Move&lt;/A&gt;, which has some great trigonometry for animation explanations.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;You can see the&amp;nbsp;results of my latest experiment &lt;A target=_blank href="http://rhizohm.net/download/netfx3/apps/planets.xbap" mce_href="http://rhizohm.net/download/netfx3/apps/planets.xbap"&gt;here&lt;/A&gt; and the code is &lt;A href="http://rhizohm.net/download/netfx3/planets/planets.zip" mce_href="http://rhizohm.net/download/netfx3/planets/planets.zip"&gt;here&lt;/A&gt;. Just to make sure I was up an running with basic trig, I created a sine wave in 01 as follows:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://wpf.netfx3.com/direct/planets"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" border=0 align=left src="http://rhizohm.net/download/netfx3/p1.jpg"&gt;&lt;/A&gt;double x = 0;&lt;BR&gt;double y = 0;&lt;BR&gt;double angle = 0;&lt;BR&gt;for (int i = 0; i &amp;lt; 500; i++)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = 200 + Math.Sin(angle) * 50;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ellipse el = new Ellipse();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; el.Width = 2;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; el.Height = 2;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; el.Fill = Brushes.Red;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Canvas.SetLeft(el, x);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Canvas.SetTop(el, y);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stage.Children.Add(el);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; angle += .05;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;Nothing fancy here.&amp;nbsp; To make a circle, I changed the x to be x = Math.Cos(angle) * 50.&amp;nbsp; This is the basis for doing circle and ellipse animations.&amp;nbsp; Now, instead of trying to do animations using &lt;STRONG&gt;CompositionTarget.Rendering&lt;/STRONG&gt;, I remembered that the SDK has a great sample called &lt;A target=_blank href="http://msdn2.microsoft.com/en-us/library/ms771715.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms771715.aspx"&gt;CustomAnimations&lt;/A&gt;, in which a CircleAnimation exists already using this formula.&amp;nbsp; Here's the key code where it overrides&amp;nbsp;the &lt;STRONG&gt;GetCurrentValueCore&lt;/STRONG&gt; method to create the circle effect using basic trig:&lt;/P&gt;
&lt;P&gt;protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock clock)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double returnValue;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double time = clock.CurrentProgress.Value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // math magic: calculate new coordinates using polar coordinate equations. This requires two &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // animations to be wired up in order to move in a circle, since we don't make any assumptions&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // about what we're animating (e.g. a TranslateTransform). &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Direction == DirectionEnum.XDirection)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnValue = Math.Cos(2 * Math.PI * time);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnValue = Math.Sin(2 * Math.PI * time);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Need to add the defaultOriginValue so that composition works.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return returnValue * Radius + defaultOriginValue;&lt;BR&gt;}&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;At first, I used this in code to create the effect of these circles circling toward you using BeginAnimation, based on the TowardUs sample in the Flash Math Creativity book (the very first sample):&lt;/P&gt;
&lt;P&gt;&lt;A href="http://wpf.netfx3.com/direct/planets"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" border=0 align=right src="http://rhizohm.net/download/netfx3/p2.jpg"&gt;&lt;/A&gt;CircleAnimation cx = new CircleAnimation();&lt;BR&gt;cx.Duration = new Duration(TimeSpan.FromSeconds(1.5));&lt;BR&gt;cx.Direction = CircleAnimation.DirectionEnum.XDirection;&lt;BR&gt;cx.Radius = 150;&lt;BR&gt;cx.RepeatBehavior = RepeatBehavior.Forever;&lt;/P&gt;
&lt;P&gt;CircleAnimation cy = new CircleAnimation();&lt;BR&gt;cy.Duration = new Duration(TimeSpan.FromSeconds(1.5));&lt;BR&gt;cy.Direction = CircleAnimation.DirectionEnum.YDirection;&lt;BR&gt;cy.Radius = 150;&lt;BR&gt;cy.RepeatBehavior = RepeatBehavior.Forever;&lt;/P&gt;
&lt;P&gt;stage.Children.Add(el);&lt;BR&gt;el.BeginAnimation(Ellipse.OpacityProperty, opacityAnimation);&lt;BR&gt;st.BeginAnimation(ScaleTransform.ScaleXProperty, d);&lt;BR&gt;st.BeginAnimation(ScaleTransform.ScaleYProperty, d);&lt;BR&gt;tt.BeginAnimation(TranslateTransform.XProperty, cx);&lt;BR&gt;tt.BeginAnimation(TranslateTransform.YProperty, cy);&lt;/P&gt;
&lt;P&gt;This resulted in 03.&amp;nbsp; It worked, but the code started getting ugly as far as getting each circle to fire when I wanted it to.&amp;nbsp; I found myself using a timer&amp;nbsp;and wiring up an anonymous delegate.&amp;nbsp;I realized &lt;STRONG&gt;Storyboards&lt;/STRONG&gt; and &lt;STRONG&gt;ParallelTimelines&lt;/STRONG&gt; would serve me much better, which are much easier to wire up in XAML than in code.&amp;nbsp; So,&amp;nbsp; 04 is the same thing, but a XAML solution instead:&lt;/P&gt;
&lt;P&gt;&amp;lt;ParallelTimeline BeginTime="0:0:0"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation&amp;nbsp; Duration="0:0:1.5" To="25" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation Duration="0:0:1.5"&amp;nbsp; To="25" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation Duration="0:0:1.5" From="1"&amp;nbsp; To="0" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.Opacity)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;CustomAnimations:CircleAnimation Duration="0:0:1.5" Radius="150" Direction="YDirection" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.Y)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;CustomAnimations:CircleAnimation Duration="0:0:1.5" Radius="150" Direction="XDirection" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.X)"/&amp;gt;&lt;BR&gt;&amp;lt;/ParallelTimeline&amp;gt;&lt;/P&gt;
&lt;P&gt;By using parallel timelines I could structure my animations and when they fired. &lt;/P&gt;
&lt;P&gt;A nice thing about this CustomAnimation is that it can be applied to 3D animations as well, applied to the &lt;STRONG&gt;TranslateTransform3D&lt;/STRONG&gt; which I did 05, changing the &lt;STRONG&gt;Radius&lt;/STRONG&gt; property to be much smaller to fit the coordinates I was using for my ViewPort.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://wpf.netfx3.com/direct/planets"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" border=0 align=left src="http://rhizohm.net/download/netfx3/p3.jpg"&gt;&lt;/A&gt;void towardus3d_Loaded(object sender, RoutedEventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sphere = new GeometryModel3D(sphereFactory.Mesh, materialGreen);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ModelVisual3D mv3d = myViewPort3D.Children[1] as ModelVisual3D;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mv3d.Content = sphere;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CircleAnimation ca3d_y = new CircleAnimation();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_y.Duration = TimeSpan.FromSeconds(5);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_y.RepeatBehavior = RepeatBehavior.Forever;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_y.Radius = .5;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_y.Direction = CircleAnimation.DirectionEnum.YDirection;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CircleAnimation ca3d_x = new CircleAnimation();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_x.Duration = TimeSpan.FromSeconds(5);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_x.RepeatBehavior = RepeatBehavior.Forever;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_x.Radius = .5;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_x.Direction = CircleAnimation.DirectionEnum.XDirection;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ModelTranslate.BeginAnimation(TranslateTransform3D.OffsetYProperty, ca3d_y);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ModelTranslate.BeginAnimation(TranslateTransform3D.OffsetXProperty, ca3d_x);&lt;BR&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It then dawned on me, as I looked at 05, an orbiting sphere, that it&amp;nbsp;would make for great planets.&amp;nbsp;&amp;nbsp;I went out to &lt;A target=_blank href="http://maps.jpl.nasa.gov/jupiter.html" mce_href="http://maps.jpl.nasa.gov/jupiter.html"&gt;NASA&lt;/A&gt; and found the texture&amp;nbsp;maps for Jupiter and its moons.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I also wanted to do all of this 3D work in XAML, so I made a class called &lt;STRONG&gt;SphereModelVisual3D&lt;/STRONG&gt; that I could instantiate Jupiter, for example, like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://wpf.netfx3.com/direct/planets"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" border=0 align=right src="http://rhizohm.net/download/netfx3/p4.jpg"&gt;&lt;/A&gt;&amp;lt;mv3d:SphereModelVisual3D x:Name="Jupiter" &amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;mv3d:SphereModelVisual3D.Material&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DiffuseMaterial&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DiffuseMaterial.Brush &amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ImageBrush ImageSource="&lt;A href="http://maps.jpl.nasa.gov/pix/jup0vss1.jpg%22/"&gt;http://maps.jpl.nasa.gov/pix/jup0vss1.jpg%22/&lt;/A&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DiffuseMaterial.Brush&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DiffuseMaterial&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/mv3d:SphereModelVisual3D.Material&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mv3d:SphereModelVisual3D.Transform&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Transform3DGroup &amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ScaleTransform3D ScaleX="2" ScaleY="2"&amp;nbsp; ScaleZ="2" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RotateTransform3D&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RotateTransform3D.Rotation&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AxisAngleRotation3D Angle="0" Axis="0 1 0" x:Name="Jupiter_rotation"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/AxisAngleRotation3D&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/RotateTransform3D.Rotation&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/RotateTransform3D&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Transform3DGroup&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/mv3d:SphereModelVisual3D.Transform&amp;gt;&lt;BR&gt;&amp;lt;/mv3d:SphereModelVisual3D&amp;gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The animation that handles the elliptical orbits needs to transform the Z property the TranslateTransform3D.&amp;nbsp; It then looks like this:&lt;/P&gt;
&lt;P&gt;&amp;lt;ParallelTimeline RepeatBehavior="Forever"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation Duration="0:0:10"&amp;nbsp; To="360"&amp;nbsp; Storyboard.TargetName="Jupiter_rotation" Storyboard.TargetProperty="Angle"/&amp;gt;&lt;BR&gt;&amp;lt;/ParallelTimeline&amp;gt;&lt;BR&gt;&amp;lt;ParallelTimeline RepeatBehavior="Forever"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;CustomAnimations:CircleAnimation Duration="0:0:2"&amp;nbsp; Radius="9" Direction="YDirection" Storyboard.TargetName="Io" Storyboard.TargetProperty="(ModelVisual3D.Transform).(Transform3DGroup.Children)[2].(TranslateTransform3D.OffsetZ)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;CustomAnimations:CircleAnimation Duration="0:0:2"&amp;nbsp; Radius="2" Direction="XDirection" Storyboard.TargetName="Io" Storyboard.TargetProperty="(ModelVisual3D.Transform).(Transform3DGroup.Children)[2].(TranslateTransform3D.OffsetX)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation Duration="0:0:2"&amp;nbsp; To="360"&amp;nbsp; Storyboard.TargetName="Io_rotation" Storyboard.TargetProperty="Angle"/&amp;gt;&lt;BR&gt;&amp;lt;/ParallelTimeline&amp;gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result is in 06. It is not astronomically correct as far as scale&amp;nbsp;-- I'll leave that for someone with some more time on their hands, but I liked the end result.&amp;nbsp; I also threw in the TrackBall control from the &lt;A target=_blank href="http://www.codeplex.com/3DTools" mce_href="http://www.codeplex.com/3DTools"&gt;3d tools project&lt;/A&gt; so you can trackball the whole model. &lt;/P&gt;
&lt;P mce_keep="true"&gt;The code is &lt;A href="http://wpf.netfx3.com/direct/planets/planets.zip" mce_href="http://wpf.netfx3.com/direct/planets/planets.zip"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1749785" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Flash/default.aspx">Flash</category></item><item><title>Inspired By Flash Math Creativity: WPF Flowers</title><link>http://blogs.msdn.com/karstenj/archive/2007/02/16/inspired-by-flash-math-creativity-wpf-flowers.aspx</link><pubDate>Fri, 16 Feb 2007 20:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1690605</guid><dc:creator>karstenj</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1690605.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1690605</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://winfx.members.winisp.net/flowers/"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" src="http://winfx.members.winisp.net/images/flower.jpg" align=right border=0&gt;&lt;/A&gt;I've recently picked up a great book called &lt;A class="" href="http://www.friendsofed.com/fmc/FMCv2/FMC.html" target=_blank mce_href="http://www.friendsofed.com/fmc/FMCv2/FMC.html"&gt;Flash Math Creativity&lt;/A&gt;.&amp;nbsp; I been inspired by some of the techniques it outlines and have played around with similar ideas in WPF.&amp;nbsp; The exercise has been a fruitful one, in that I'm making some pleasing computer art while also learning about the differences between Action Script animation and WPF animation.&amp;nbsp; The first one I played with is flowers, inspired by the work of &lt;A class="" href="http://www.glenrhodes.com/" target=_blank mce_href="http://www.glenrhodes.com "&gt;Glen Rhodes&lt;/A&gt;, which is actually featured on the cover of the book.&amp;nbsp; You can &lt;A class="" href="http://winfx.members.winisp.net/flowers/" target=_blank mce_href="http://winfx.members.winisp.net/flowers/"&gt;see the results here&lt;/A&gt; and &lt;A class="" href="http://winfx.members.winisp.net/flowers.zip" mce_href="http://winfx.members.winisp.net/flowers.zip"&gt;download the code here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;The first flower, which has no animation, is pretty simple. I just create 125 rectangles with a fill using a DrawingBrush I created in Blend.&amp;nbsp; I place each of the petals on the "stage", which in the case is a &lt;STRONG&gt;Grid&lt;/STRONG&gt;.&amp;nbsp; I use &lt;STRONG&gt;Grid&lt;/STRONG&gt; instead of &lt;STRONG&gt;Canvas&lt;/STRONG&gt; so that I get the goodness of the WPF layout engine for free without having to handle any positioning of the rectangles.&amp;nbsp; I then tranform the rotation and scale of each one to create the flower effect.&amp;nbsp; I also swap the ZIndex so that the large petals are in back and the smaller ones are in front. &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;void OnLoaded(object sender, EventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int r = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double s = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i=0; i &amp;lt; 125; i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rectangle rect = new Rectangle();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rect.Width = 50;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rect.Height = 50;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rect.Fill = (DrawingBrush)this.FindResource("petal");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TransformGroup tg = new TransformGroup();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s += .01;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ScaleTransform st = new ScaleTransform(s * s * s + .1, s * s * s + .1);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r += 27;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RotateTransform rt = new RotateTransform(r);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tg.Children.Add(st);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tg.Children.Add(rt);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rect.RenderTransform = tg;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Grid.SetZIndex(rect, -i);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stage.Children.Add(rect);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;&lt;A href="http://winfx.members.winisp.net/flowers/"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" src="http://winfx.members.winisp.net/images/flower2.jpg" align=left border=0&gt;&lt;/A&gt;Where things get a little more interesting is when it comes to animating the flower. In Action Script, this kind of dynamic animation is handled through the very convenient &lt;STRONG&gt;onEnterFrame&lt;/STRONG&gt;.&amp;nbsp; This handler provides a per-frame callback for each individual movie clip, in which a function can be wired up.&amp;nbsp; There is no equivalent in WPF such that you get a per-frame callback &lt;EM&gt;for each element&lt;/EM&gt;.&amp;nbsp; The&amp;nbsp;closest thing to this concept is the &lt;STRONG&gt;CompositionTarget.Rendering&lt;/STRONG&gt; handler, which gets called per-frame for the entire tree (or page or stage, if you will.) &lt;/P&gt;
&lt;P&gt;It is possible to find each element you are looking for when this event gets fired and achieve a similar effect to &lt;STRONG&gt;onEnterFrame&lt;/STRONG&gt;.&amp;nbsp; I did just this in Page3.xaml, which ends up adding the following in addition to the loaded method:&lt;/P&gt;
&lt;P mce_keep="true"&gt;void CompositionTarget_Rendering(object sender, EventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (UIElement uie in stage.Children)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TransformGroup tg = uie.RenderTransform as TransformGroup;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ScaleTransform st = tg.Children[0] as ScaleTransform;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (st.ScaleX &amp;gt; -3)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; st.ScaleX -= .1;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can see how I end up having to walk the tree, extracting the children and then acting on the children.&amp;nbsp; While this works, there are several disadvantages to this methodology.&amp;nbsp; First, having to figure out the animation for every UI element within a single callback has the potential to get quite unwieldy.&amp;nbsp; Second, using this method means we don't get all of the goodness of the WPF animation system, things like frame rate indepence, timelines, storyboards, repeat behaviors, autoreverse, etc.&amp;nbsp; So, let's see what this animation would look like using the WPF animation system:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://winfx.members.winisp.net/flowers/"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" src="http://winfx.members.winisp.net/images/flower3.jpg" align=right border=0&gt;&lt;/A&gt;void Page2_Loaded(object sender, RoutedEventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int r = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double s = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoubleAnimation d = new DoubleAnimation(-3, new Duration(TimeSpan.FromSeconds(2)));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; d.AutoReverse = true;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; d.RepeatBehavior = RepeatBehavior.Forever;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; 125; i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rectangle rect = new Rectangle();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rect.Width = 50;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rect.Height = 50;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rect.Opacity = .5;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rect.Fill = (DrawingBrush)this.FindResource("petal2");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TransformGroup tg = new TransformGroup();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s += .01;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ScaleTransform st = new ScaleTransform(s * s * s + .1, s * s * s + .1);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r += 27;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RotateTransform rt = new RotateTransform(r);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tg.Children.Add(st);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tg.Children.Add(rt);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rect.RenderTransform = tg;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Grid.SetZIndex(rect, -i);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; st.BeginAnimation(ScaleTransform.ScaleXProperty, d);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stage.Children.Add(rect);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;With this code, I get to wire up an animation to each element -- in fact I'm wiring up the same animation, which simply animates the scale.&amp;nbsp; I get to use some of the features of the animation system, like AutoReverse and RepeatBehaviors.&amp;nbsp; And, I'm letting WPF calculate the timing instead of me doing it per-frame.&amp;nbsp; Much nicer, methinks.&lt;/P&gt;
&lt;P&gt;Those seasoned with the WPF samples can probably deduce where I derived the harness you toggle between the different animations. I took the basic idea from &lt;A class="" href="http://wpf.netfx3.com/files/folders/controls/entry8196.aspx" target=_blank mce_href="http://wpf.netfx3.com/files/folders/controls/entry8196.aspx"&gt;Kevin Moore's Bag-o-Tricks&lt;/A&gt; and then added the fading between frames from the custom frame in the WPF Feature Fest sample.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I'm also now pointing all my WPF samples to an HTML page which checks to see if you have the framework installed and directs you to where you get it if you don't.&amp;nbsp; I took this from the Windows SDK and modified to to auto-redirect if .NET 3.0 is installed.&amp;nbsp; It is included in the source.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1690605" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Action+Script/default.aspx">Action Script</category></item><item><title>WPF Application Portfolio Wiki Updated -- More WPF Apps!</title><link>http://blogs.msdn.com/karstenj/archive/2007/02/09/wpf-application-portfolio-wiki-updated.aspx</link><pubDate>Sat, 10 Feb 2007 01:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1638052</guid><dc:creator>karstenj</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1638052.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1638052</wfw:commentRss><description>&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/tims" target=_blank mce_href="http://blogs.msdn.com/tims"&gt;Tim Sneath&lt;/A&gt;&amp;nbsp;has been doing a great job of blogging the many Vista/WPF showcase applications that are being deployed right now.&amp;nbsp; If you are looking for a quick list of URLs that you can hit for the .XBAP or .APPLICATION files, please go to the &lt;A class="" href="http://channel9.msdn.com/wiki/default.aspx/WPF.ApplicationPortfolio" target=_blank mce_href="http://channel9.msdn.com/wiki/default.aspx/WPF.ApplicationPortfolio"&gt;WPF Application Portfolio wiki&lt;/A&gt;, which I've updated with all the links, tagging them with the kind of deployment used -- very cool to see the number of .application and .xbap applications out there!&amp;nbsp; If you are doing a demo and trying to show someone the WPF portfolio, hopefully this wiki page will be useful -- and watch for more coming...&lt;/P&gt;
&lt;P&gt;I've also added some that Tim hasn't documented yet, in particular a whole bunch from Japan, as well as one from Metaliq on snowboarding visualization. Some screenshots below.&amp;nbsp; &lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;A href="http://www.metaliq.com/wpf/"&gt;http://www.metaliq.com/wpf/&lt;/A&gt;&amp;nbsp;&lt;BR&gt;&lt;A href="http://weathernews.com/wpfglobal.xbap"&gt;&lt;FONT size=2&gt;http://weathernews.com/wpfglobal.xbap&lt;/FONT&gt;&lt;/A&gt;&lt;BR&gt;&lt;A href="http://sp.warnermycal.com/vista/contents/preview.xbap"&gt;&lt;FONT size=2&gt;http://sp.warnermycal.com/vista/contents/preview.xbap&lt;/FONT&gt;&lt;/A&gt;&lt;BR&gt;&lt;A href="http://www.shiseido.co.jp/biyou_dic_vista/shiseido.xbap"&gt;&lt;FONT size=2&gt;http://www.shiseido.co.jp/biyou_dic_vista/shiseido.xbap&lt;/FONT&gt;&lt;/A&gt;&lt;BR&gt;&lt;A href="http://www.dosv.jp/parts_assembler/PartsAssembler.xbap"&gt;&lt;FONT size=2&gt;http://www.dosv.jp/parts_assembler/PartsAssembler.xbap&lt;/FONT&gt;&lt;/A&gt;&lt;BR&gt;&lt;A href="http://japan.cnet.com/wpf/photo/"&gt;&lt;FONT size=2&gt;http://japan.cnet.com/wpf/photo/&lt;/FONT&gt;&lt;/A&gt;&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 1024px; HEIGHT: 768px" height=768 src="http://www.metaliq.com/wpf/images/screen2full.jpg" width=1024 mce_src="http://www.metaliq.com/wpf/images/screen2full.jpg"&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 697px; HEIGHT: 377px" height=377 src="http://winfx.members.winisp.net/images/1.png" width=697 mce_src="http://winfx.members.winisp.net/images/1.png"&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 584px; HEIGHT: 400px" height=400 src="http://winfx.members.winisp.net/images/2.png" width=584 mce_src="http://winfx.members.winisp.net/images/2.png"&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 700px; HEIGHT: 425px" height=425 src="http://winfx.members.winisp.net/images/3.png" width=700 mce_src="http://winfx.members.winisp.net/images/3.png"&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1638052" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/weblive/default.aspx">weblive</category></item><item><title>Announcing Expression Blend Beta 2 and Expression Design Beta 1</title><link>http://blogs.msdn.com/karstenj/archive/2007/01/30/announcing-expression-blend-beta-2-and-expression-design-beta-1.aspx</link><pubDate>Wed, 31 Jan 2007 08:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1561764</guid><dc:creator>karstenj</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1561764.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1561764</wfw:commentRss><description>&lt;P&gt;You can now go download &lt;A class="" href="http://www.microsoft.com/products/expression/en/Expression-Blend/try.mspx" target=_blank mce_href="http://www.microsoft.com/products/expression/en/Expression-Blend/try.mspx"&gt;Expression Blend Beta 2&lt;/A&gt; as well as &lt;A class="" href="http://www.microsoft.com/products/expression/en/expression-design/free-trial.mspx" target=_blank mce_href="http://www.microsoft.com/products/expression/en/expression-design/free-trial.mspx"&gt;Expression Design Beta 1&lt;/A&gt;. Both applications have received significant work since their last incarnation with tons of bugs fixed. Go give 'em a whirl.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 312px; HEIGHT: 213px" height=213 src="http://www.microsoft.com/products/expression/en/images/ex-blend/boxShot_Blend.jpg" width=312 mce_src="http://www.microsoft.com/products/expression/en/images/ex-blend/boxShot_Blend.jpg"&gt;&lt;IMG style="WIDTH: 312px; HEIGHT: 213px" height=213 src="http://www.microsoft.com/products/expression/en/images/ex-design/boxShot_Design.jpg" width=312 mce_src="http://www.microsoft.com/products/expression/en/images/ex-design/boxShot_Design.jpg"&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1561764" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Expression+Blend/default.aspx">Expression Blend</category></item><item><title>Databinding In Expression Blend: Forget the Data and Do the Bind</title><link>http://blogs.msdn.com/karstenj/archive/2007/01/26/databinding-in-expression-blend-forget-the-data-and-do-the-bind.aspx</link><pubDate>Fri, 26 Jan 2007 23:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1538016</guid><dc:creator>karstenj</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1538016.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1538016</wfw:commentRss><description>&lt;P&gt;I just posted a &lt;A class="" href="http://channel9.msdn.com/ShowPost.aspx?PostID=276212" target=_blank mce_href="http://channel9.msdn.com/ShowPost.aspx?PostID=276212"&gt;screencast&lt;/A&gt; showing how to wire up UI elements using Blend.&amp;nbsp; The general premise is that databinding in WPF is about more&amp;nbsp;than just data; it also allows you to connect UI properties, like wiring a slider up to a progress bar. Blend exposes this is a very useable way, once you know your way around.&amp;nbsp; I also use some cool styles from this &lt;A href="http://msdn.microsoft.com/msdnmag/issues/07/01/Foundations/default.aspx"&gt;Charles Petzold article&lt;/A&gt;&amp;nbsp;and show how, in Blend, you can extract a style and template from a piece of XAML to be reused in other parts of your application.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 400px; HEIGHT: 424px" height=424 src="http://msdn.microsoft.com/msdnmag/issues/07/01/Foundations/fig12.gif" width=400 mce_src="http://msdn.microsoft.com/msdnmag/issues/07/01/Foundations/fig12.gif"&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1538016" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category></item><item><title>Doninoken: WPF XBAP Piece by Bascule</title><link>http://blogs.msdn.com/karstenj/archive/2007/01/25/doninoken-wpf-xbap-piece-by-bascule.aspx</link><pubDate>Thu, 25 Jan 2007 23:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1531418</guid><dc:creator>karstenj</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1531418.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1531418</wfw:commentRss><description>&lt;P&gt;Check out &lt;A class="" href="http://www.microsoft.com/japan/windowsvista/webshowcase/domino.htm" target=_blank mce_href="http://www.microsoft.com/japan/windowsvista/webshowcase/domino.htm"&gt;Doninoken&lt;/A&gt;, an amazing WPF piece that is part of the Japanese Vista launch, done by the design agency &lt;A class="" href="http://bascule.co.jp/" target=_blank mce_href="http://bascule.co.jp/"&gt;Bascule&lt;/A&gt;.&amp;nbsp;&amp;nbsp; The aesthetic is amazing.&amp;nbsp; I love how they use WPF 3D, mapping images on planes and animating the planes.&amp;nbsp;(Watch for the small camera that pops up after the title screen that lets you interact with the app and zoom the camera around.) &amp;nbsp;Still, how did they do it?&amp;nbsp; Maya exports? Hand tweaking XAML?&amp;nbsp; It is very impressive. And makes you want some sushi...&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://www.microsoft.com/japan/windowsvista/webshowcase/domino.htm" target=_blank mce_href="http://www.microsoft.com/japan/windowsvista/webshowcase/domino.htm" border="0"&gt;&lt;IMG style="WIDTH: 750px; HEIGHT: 650px" height=650 src="http://www.microsoft.com/japan/windowsvista/webshowcase/images/domino.jpg" width=750 border=0 mce_src="http://www.microsoft.com/japan/windowsvista/webshowcase/images/domino.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1531418" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category></item><item><title>The Definitive Post on XBAP Trust Levels</title><link>http://blogs.msdn.com/karstenj/archive/2007/01/11/the-definitive-post-on-xbap-trust-levels.aspx</link><pubDate>Fri, 12 Jan 2007 00:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1452289</guid><dc:creator>karstenj</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1452289.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1452289</wfw:commentRss><description>I've written about XBAPs and full trust in the past, but never as thoroughly as Karen Corby just did in her post on &lt;A class="" href="http://scorbs.com/2007/01/10/xbap-trust-levels/" target=_blank mce_href="http://scorbs.com/2007/01/10/xbap-trust-levels/"&gt;XBAP trust levels&lt;/A&gt;.&amp;nbsp; She spent a lot of time getting this post correct, reviewing with various folks within Microsoft and providing very solid guidance.&amp;nbsp; It is the kind of post that should be in the SDK and official docs, but didn't make it due to time constraints.&amp;nbsp; If you have questions about XBAPs and full trust, this is a must read.&amp;nbsp; Her deployment recommendations in particular are essential if you are thinking about going down the full trust XBAP road.&amp;nbsp; But keep her guidance in mind: only do this if you must.&amp;nbsp; ClickOnce .exe's are pretty slick and don't have nearly the issues associated with them as full trust .xbaps. &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1452289" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Vista/default.aspx">Vista</category></item><item><title>Yahoo Messenger for Vista Debuts at CES</title><link>http://blogs.msdn.com/karstenj/archive/2007/01/09/yahoo-messenger-for-vista-debuts-at-ces.aspx</link><pubDate>Tue, 09 Jan 2007 20:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1439896</guid><dc:creator>karstenj</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1439896.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1439896</wfw:commentRss><description>&lt;P&gt;I'm here at CES, where Yahoo and Microsoft&amp;nbsp;showed off a preview of the new Yahoo Messenger for Vista, built entirely on WPF.&amp;nbsp; Yahoo has &lt;A class="" href="http://messenger.yahoo.com/windowsvista.php" target=_blank mce_href="http://messenger.yahoo.com/windowsvista.php"&gt;a great landing page&lt;/A&gt; with screenshots, a screencast of the app and a sign up sheet for when they release a beta.&amp;nbsp; I held off on blogging this until we got the Channel 10 interview posted, where I hooked up with &lt;A class="" href="http://www.jeffsandquist.com/" target=_blank mce_href="http://www.jeffsandquist.com/"&gt;Jeff Sandquist&lt;/A&gt; and the crew to do &lt;A class="" href="http://www.on10.net/Blogs/larry/yahoo-messenger-on-wpf/" target=_blank mce_href="http://www.on10.net/Blogs/larry/yahoo-messenger-on-wpf/"&gt;an interview with the Yahoo folks&lt;/A&gt;, Joshua Jacobson and Matthew Skyrm, about the application.&amp;nbsp; (If you haven't seen Channel 10, it is the sister to Channel 9, targeted to&amp;nbsp;enthusiasts and power users.) They talk about their motivations for building this new messenger, their experience with WPF and Expression and more.&amp;nbsp; They've got a &lt;A class="" href="http://blog.messenger.yahoo.com/blog/2007/01/08/introducing-yahoo-messenger-for-windows-vista/" target=_blank mce_href="http://blog.messenger.yahoo.com/blog/2007/01/08/introducing-yahoo-messenger-for-windows-vista/"&gt;blog&lt;/A&gt; up as well!&amp;nbsp; I've been working with the lead developer, &lt;A class="" href="http://eric.burke.name/dotnetmania/" target=_blank mce_href="http://eric.burke.name/dotnetmania/"&gt;Eric Burke&lt;/A&gt;, along with &lt;A class="" href="http://www.frogdesign.com/" mce_href="http://www.frogdesign.com"&gt;Frog Design&lt;/A&gt;, including &lt;A class="" href="http://thewpfblog.com/?p=76" target=_blank mce_href="http://thewpfblog.com/?p=76"&gt;Lee Brimelow&lt;/A&gt;, on this application and the alpha is looking great. This application is a shining example of the opportunities and possibilities of the Vista and .NET 3.0 platform. Expect to hear more about this, for sure...&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 600px; HEIGHT: 547px" height=547 src="http://us.i1.yimg.com/us.yimg.com/i/us/msg/vista/buddy_list_05.jpg" width=600 mce_src="http://us.i1.yimg.com/us.yimg.com/i/us/msg/vista/buddy_list_05.jpg"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1439896" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Vista/default.aspx">Vista</category></item><item><title>Gradient Animation Obsession Redux</title><link>http://blogs.msdn.com/karstenj/archive/2007/01/04/gradient-animation-obsession-redux.aspx</link><pubDate>Fri, 05 Jan 2007 01:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1412842</guid><dc:creator>karstenj</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1412842.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1412842</wfw:commentRss><description>&lt;P&gt;I guess I didn't call it an obsession without reason, as I can't seem to keep away from those hyponotizing gradient animations.&amp;nbsp; I modified the tool I posted last month so that it would output the XAML, such that a designer could actually use the tool and never touch a line of XAML.&amp;nbsp; I set up the tool to output either WPF or WPF/E XAML, as WPF/E doesn't support everything (yet) that the tool uses, such as &lt;STRONG&gt;AccelerationRatio&lt;/STRONG&gt;, as well as having a different namespace.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I ran into some problems with &lt;STRONG&gt;XAMLWriter&lt;/STRONG&gt; and the way it strips x:Name from the XAML it produces, so there is some hacky string replace code in there that I'm not proud of.&amp;nbsp;&amp;nbsp;I could have used property paths as an alternative.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because you can't use &lt;STRONG&gt;XAMLWriter&lt;/STRONG&gt; in an XBAP, I made the tool a ClickOnce .application that doesn't get installed on your machine but just runs in the ClickOnce cache.&amp;nbsp; Hopefully, we'll see more and more of these types of apps -- mini applications that never get installed but can do more than in-browser applications.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://www.rhizohm.net/download/netfx3/gradientobsessionapp.zip" mce_href="http://www.rhizohm.net/download/netfx3/gradientobsessionapp.zip"&gt;Download the source&lt;/A&gt; or &lt;A target=_blank href="http://www.rhizohm.net/download/netfx3/apps/gradientobsessionapp.application" mce_href="http://www.rhizohm.net/download/netfx3/apps/gradientobsessionapp.application"&gt;run the tool&lt;/A&gt;.&amp;nbsp;&amp;nbsp; Also, check out some of the gradient animations I made with the tool and put into a &lt;A target=_blank href="http://winfx.members.winisp.net/wpfe/GradientObsession/" mce_href="http://winfx.members.winisp.net/wpfe/GradientObsession/"&gt;WPF/E page&lt;/A&gt; here (screenshot below, although it doesn't do justice to the hypnotizing effect...)&lt;/P&gt;
&lt;P&gt;&lt;A target=_blank href="http://winfx.members.winisp.net/wpfe/GradientObsession/" mce_href="http://winfx.members.winisp.net/wpfe/GradientObsession/" border="0"&gt;&lt;IMG style="WIDTH: 512px; HEIGHT: 424px" border=0 src="http://winfx.members.winisp.net/images/gradientsoup.jpg" width=512 height=424 mce_src="http://winfx.members.winisp.net/images/gradientsoup.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1412842" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF_2F00_e/default.aspx">WPF/e</category></item><item><title>The North Face In-Store Explorer</title><link>http://blogs.msdn.com/karstenj/archive/2007/01/02/the-north-face-in-store-explorer.aspx</link><pubDate>Tue, 02 Jan 2007 21:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1399923</guid><dc:creator>karstenj</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1399923.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1399923</wfw:commentRss><description>&lt;P&gt;It was at PDC 2005 when &lt;A class="" href="http://channel9.msdn.com/ShowPost.aspx?PostID=116426" target=_blank mce_href="http://channel9.msdn.com/ShowPost.aspx?PostID=116426"&gt;The North Face showed a prototype of a WPF kiosk&lt;/A&gt; they were building.&amp;nbsp; Well, with Vista and WPF having RTM'd, the real kiosk has been deployed, which you can read about from &lt;A class="" href="http://flog.fluid.com/2006/12/19/the-north-face-in-store-explorer-is-live/" target=_blank mce_href="http://flog.fluid.com/2006/12/19/the-north-face-in-store-explorer-is-live/"&gt;lead engineer Darren David at Fluid's blog&lt;/A&gt;.&amp;nbsp; (Fluid is the agency that did the work for The North Face.)&amp;nbsp; If you live near a &lt;A class="" href="http://thenorthface.com/na/store-locations.html" target=_blank mce_href="http://thenorthface.com/na/store-locations.html"&gt;North Face retail store&lt;/A&gt;, go check it out!&amp;nbsp; This is an exciting milestone for WPF and Vista, as it is one of the most ambitious .NET 3.0/Vista applications deployed to date.&amp;nbsp; Note that &lt;A class="" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/fluid.asp" target=_blank mce_href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/fluid.asp"&gt;the white paper&lt;/A&gt; written about this application is still relevant and worth reading.&amp;nbsp;&amp;nbsp; The code samples all work just fine on the final bits&amp;nbsp;and have some useful code as far as state management,&amp;nbsp;image montages and a 3D carousel.&lt;/P&gt;
&lt;P&gt;&lt;IMG title="The North Face In-Store Explorer" style="WIDTH: 640px; HEIGHT: 512px" height=512 alt="The North Face In-Store Explorer" src="http://winfx.members.winisp.net/images/tnf.jpg" width=640 mce_src="http://winfx.members.winisp.net/images/tnf.jpg"&gt;&amp;nbsp; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1399923" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category></item><item><title>Gradient Obsession: A Tool For Tweaking Gradient Animations</title><link>http://blogs.msdn.com/karstenj/archive/2006/12/12/gradient-obsession-a-tool-for-tweaking-gradient-animations.aspx</link><pubDate>Wed, 13 Dec 2006 01:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1268652</guid><dc:creator>karstenj</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1268652.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1268652</wfw:commentRss><description>&lt;P&gt;I started getting slightly obsessed/hypnotized with gradient animations and wanted a tool to see what I could do, so I built one.&amp;nbsp; Basically, I just bound a bunch of sliders to the various transforms on the brush transform.&amp;nbsp; I reused the infrastructure from an earlier post.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;As you watch the animation and see something you like, you can pause it and note the values for your own purpose.&amp;nbsp; I didn't actually create an exporter for the xaml, but that wouldn't&amp;nbsp;be hard.&amp;nbsp; &lt;A href="http://rhizohm.net/download/netfx3/gradientobsessionapp.zip" mce_href="http://rhizohm.net/download/netfx3/gradientobsessionapp.zip"&gt;Download the source&lt;/A&gt; or &lt;A target=_blank href="http://rhizohm.net/download/netfx3/apps/gradientobsessionapp.application" mce_href="http://rhizohm.net/download/netfx3/apps/gradientobsessionapp.application"&gt;run the XBAP&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://wpf.netfx3.com/direct/gradientobsession/gradientobsession.xbap" border="0"&gt;&lt;IMG border=0 src="http://winfx.members.winisp.net/images/torustripapp.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1268652" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category></item></channel></rss>