JakeHorner
Possibly the world's best jake.
I love the web. The web should allow anyone to access any experience that they need without the need for native install or content walled garden.
Possibly the world's best jake.
A weekly run-down for Feb
I recently discovered a cool trick in WebKit that lets you use a canvas element as a background image, which opens up a ton of creative possibilities. It's a powerful feature, allowing for dynamic, programmatic manipulation of background images. I've included a simple demo showing how to draw a square on a div's background, but imagine the possibilities for games or complex animations! While currently WebKit-specific, I hope other browsers will adopt it soon. More demos to follow!
DoubleAnimation crashes in XAMLPad (May CTP) when animating Width or Height without specifying both "From" and "To" values, or when a base value isn't set. This is because the animation infers these values from the base value, which may not be available until layout execution. Setting the Width or Height on the element or in a style usually resolves the issue. However, I encountered a case where animating a MenuItem's width failed even after attempting to set a default width through a style. A suggested solution involved explicitly setting the width on the element, as the animation infers the 'To' value from the base value, which needs to be available for a smooth transition. I then tried setting a default Width on the MenuItem Style and the crash still occurs in XAMLPad. My next step is to test this in a WinFX application.
I've found answers to my XAML menu throbbing questions! Using RoutedEvents in ControlTemplates (and DataTemplates!) lets me start and stop timelines for animations. I can place these triggers inside styles, and it turns out TargetName isn't always required. A cool discovery: storyboards inside ControlTemplates/DataTemplates can be accessed by any control matching the style's TargetType. My wobbly menu example demonstrates these techniques.
I've encountered a crash in XAMLPad (May CTP) when animating the width of a MenuItem. Specifically, if I remove the "From" attribute in a DoubleAnimation within a SetterTimeline, XAMLPad crashes. I expected the animation to start from the MenuItem's default width. Is this the correct way to use DoubleAnimation without specifying "From"? The crash occurs in a specific context: the Timeline is defined within a Style applied to a HeaderTemplate's DataTemplate element for a custom-drawn control. See the linked XAML for a complete example.
I had this cool idea to add some throbbing action to my GelButton menu items in XAML. I wanted them to subtly pulse when hovered over. Turns out, it's harder than I thought! I've learned some limitations in XAML (May CTP): you can't start/stop storyboards from triggers, apply a single animation to all controls of a type, and TargetID is deprecated in favor of TargetName. Points 1 & 2 are especially problematic as they blur the lines between UI and application logic. I'm going to look for workarounds and see if others have solutions. Might even post my (probably wrong) ideas on how things should work.
A quick follow-up to my last post about the XAML menu example: It no longer uses the Animated Gel Button animation, and the GelButton code modification I mentioned actually came from a different page on the same site I linked previously.