. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Friday, June 10, 2005

DoubleAnimation Crashes XAMLPad (MayCTP): Some Answers To Questions

I posted around some news groups to find an answer about my crash and a I recieved the following reply from Mike Hillbert.

When you're animating Width or Height, you have to specify both the From and the To, or you have to have specified the base value somewhere (e.g. on the element itself).

That's because when you don't specify the From or To it gets inferred from the base (unanimated) value. And in the case of Width and Height, the base value often isn't known until later when layout runs.

For example, in this page

<Page ...>
...
<Page.Storyboards>
<SetterTimeline TargetName="btn" Path="(Button.Width)" >
<DoubleAnimation From="50" />
</SetterTimeline>
</Page.Storyboards>
...
<Button Width="100" Name="btn" Background="Blue">Click</Button>
...
</Page>

the button's width is explicitly set on the <Button>, so the animation implicitly takes the width to 100 (from 50). But if you don't have the Width set in the <Button>, and don't have it anywhere else (e.g. in a Style), you have to have the From on the DoubleAnimation.


I think it basically sums up the problem quite simply. I wasn't giving the actual MenuItem a width, the "Owner Draw" elements in the Visual Tree had a width but the actual menu item didn't. Funnily enough (Well it is not that funny), I tried the suggested fixes and the crash was still occuring. I also tried the following bit of XAML which is supposed to give every control that meets the style criteria a width of 200:

<Style TargetType="{x:Type MenuItem}" x:Key="{x:Type MenuItem}" >
<Setter Property="Width" Value="200" />
...
...


I think my next course of action is to try and get this in a proper WinFX application rather than just XAMLPad.

Comments: [Add New]