Can anyone explain why this throws an exception?
<UserControl> <Grid> <Grid.Margin> <Thickness x:Name="thickness" /> </Grid.Margin> </Grid> </UserControl>
If I remove the x:Name
attribute, then it runs successfully.
Error details:
Message: Unhandled Error in Silverlight Application Code: 4004
Category: ManagedRuntimeError
Message: System.NullReferenceException: Object reference not set to an instance of an object. at SilverlightBindingTest.MainPage.InitializeComponent() at SilverlightBindingTest.MainPage..ctor() at SilverlightBindingTest.App.Application_Startup(Object sender, StartupEventArgs e) at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)
Answer: 1
The Name attribute is a DependencyObject and as such can only be set on another DependencyObject.
Thickness is not a DependencyObject, so you cannot use the Name attribute.
by : TriggerPinhttp://stackoverflow.com/users/1549726
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog