Hey all,
I'm getting an odd error (oh wait, all of the Silverlight errors are odd ;)
Additional information: System.Exception: Catastrophic failure (Exception
from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[]
cvData)
at System.Windows.DependencyObject.MethodEx(String methodName, CValue[]
cvData)
at System.Windows.Media.Animation.Storyboard.Begin()
at PTN.Controls.CustomButton.CustomButton_MouseEnter(Object sender,
MouseEventArgs e)
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex,
Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr
unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
The exception is thrown when I try to call a storyboard Begin method. The
strange thing is that my code works fine if my custom control is within a
stackpanel inside a grid, but if I put the whole lot inside a TabItem
control then it breaks.
Has anyone seen that?
cheers,
Stephen
<ControlsExtended:TabItem Header="Button Example" >
<StackPanel x:Name="stack" HorizontalAlignment="Left">
<ptn:CustomButton x:Name="button0" Width="100" HorizontalAlignment="Left" >
<Image Source="images/pic1.png" />
</ptn:CustomButton>
<StackPanel>
</ControlsExtended:TabItem>
//My custom button here
public class CustomButton : Button {
public Storyboard enterStoryboard;
public CustomButton() {
Loaded += delegate {
SetupAnimateEnter();
MouseEnter += new
MouseEventHandler(CustomButton_MouseEnter);
};
}
public void CustomButton_MouseEnter(object sender, MouseEventArgs e)
{
enterStoryboard.Begin();
}
public void SetupAnimateEnter() {
TimeSpan time = TimeSpan.FromSeconds(0.2);
Duration duration = new Duration(time);
// Target size is modified later by calculations based on mouse
position
double targetSize = 100 * 1.4;
if (!double.IsNaN(targetSize) && targetSize > 0) {
DoubleAnimation magnifyAnimation = new DoubleAnimation {
Duration = duration, To = targetSize };
if (enterStoryboard == null) {
enterStoryboard = new Storyboard { Duration = duration
};
}
enterStoryboard.Children.Add(magnifyAnimation);
Storyboard.SetTarget(magnifyAnimation, this);
Storyboard.SetTargetProperty(magnifyAnimation, new
PropertyPath("Width"));
this.Resources.Add("magnifyEnter", enterStoryboard);
}
}
}
-------------------------------------------------------------------
OzSilverlight.com - to unsubscribe from this list, send a message back to the
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net