例外:无法在“空白矩形"上修改此属性. [英] Exception: Cannot modify this property on the Empty Rect.

查看:76
本文介绍了例外:无法在“空白矩形"上修改此属性.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我遇到一个例外:无法在Empty Rect上修改此属性."在我的应用程序中.
关于我的项目的简短描述是:我有一个项目,以椭圆形布局为元素.为此,我构建了一个包含Viewport3D对象的自定义面板,该面板承载着子元素,并且在ArrangeOverride()方法期间,我正在计算椭圆圆周上的点并将该元素放置在该位置上.我正在使用ArrangeOverride()和MeasureOverride()方法来布局和测量放置在椭圆布局上的元素的大小.因此,如果我放置普通元素(例如按钮,文本),则它可以正常工作.但是,如果我将此面板作为ItemsPanel for列表框,则当我单击某个项目时,无法在Empty Rect上修改此属性".异常来了.我没有得到如何解决此异常的方法.请帮助我解决此异常.我将附加调用堆栈以供您参考.

未处理System.InvalidOperationException
消息=无法在Empty Rect上修改此属性."
Source =" WindowsBase"
> StackTrace:
,位于System.Windows.Rect.set_X(双精度值)
,位于System.Windows.Controls.ScrollContentPresenter.MakeVisible(可视外观,Rect矩形,布尔型throwOnError)
在System.Windows.Controls.ScrollViewer.ExecuteNextCommand()处
在System.Windows.Controls.ScrollViewer.OnLayoutUpdated(Object sender,EventArgs e)
在System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
在System.Windows.ContextLayoutManager.UpdateLayout()
在System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)在System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
在System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
在System.Win dows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
在System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate回调,Object args,布尔值isSingleParameter)
在System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象args,布尔值isSingleParameter,委托catchHandler)
在System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate回调) ,对象args,布尔值isSingleParameter,委托catchHandler)
在System.Windows.Threading.DispatcherOperation.InvokeImpl()
在System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(对象状态)在系统中.Threading.ExecutionContext.runTryCode(Object userData)
在System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode代码,CleanupCode backoutCode,对象userData)
在System.Threading.ExecutionContext.RunInternal(ExecutionContext executeContext,ContextCallback回调,对象状态)
在System.Threading.ExecutionContext.Run(ExecutionContext executeContext,ContextCallback回调,对象状态)<在System.Windows.Threading.DispatcherOperation.Invoke()处
在System.Windows.Threading.Dispatcher.ProcessQueue()处在System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,布尔值和已处理)
在MS.Win32.HwndWrapper.WndProc(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,布尔值和已处理) >在System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate回调,对象参数,布尔isSingleParameter)
在System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象参数,布尔isSingleParameter,委托catchHandler )
在System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调,对象参数,布尔值isSingleParameter,委托catchHandler)
在System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority优先级,TimeSpan超时, System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority优先级,Delegate方法,Object arg)中的方法,对象参数,布尔值isSingleParameter)
在MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd,I nt32 msg,IntPtr wParam,IntPtr lParam)
在MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
在System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
在System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
在System.Windows.Threading.Dispatcher .Run()
在System.Windows.Application.RunDispatcher(对象忽略)
在System.Windows.Application.RunInternal(窗口窗口)
在System.Windows.Application.Run(Window window)
在System.Windows.Application.Run()
在Ellipse3DLayoutTestapp.App.Main()在D:\ WPF \ Dicomv \ Ellipse3DLayoutTestapp \ obj \ Debug \ App.g.cs:line 0在System.AppDomain._nExecuteAssembly(装配程序集,String [] args)中的

在Microsoft.VisualStudio中在System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)中的
在Microsoft.VisualStudio中. HostingProcess.HostProc.RunUsersAssembly()
在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)
在System.Threading.ExecutionContex在System.Threading.ThreadHelper.ThreadStart()处的t.Run(ExecutionContextexecutionContext,ContextCallback回调,对象状态)

Hi All,

i am getting an exception: "Cannot modify this property on the Empty Rect." in my application.
Brief description about my project is that; I have a project which arrages the elements in elliptical layout. for this i had build one custom panel containing the Viewport3D object, which hosts the child elements and during ArrangeOverride() method i am calculating the point on elliptical circumference and placing the the element on the position. i am ovrriding both ArrangeOverride() and MeasureOverride() method to layout and measure the size of the elements which i am placing on the elliptical layout. So if i place normal elements like button, text, it is working properly. But if i make this panel as ItemsPanel for list box, when i click an item, then "Cannot modify this property on the Empty Rect." exception is comming. I am not getting how to fix this exception. Please help me to fix this exception. I am attaching the call stack for your reference.

System.InvalidOperationException was unhandled
  Message="Cannot modify this property on the Empty Rect."
  Source="WindowsBase"
  StackTrace:
       at System.Windows.Rect.set_X(Double value)
       at System.Windows.Controls.ScrollContentPresenter.MakeVisible(Visual visual, Rect rectangle, Boolean throwOnError)
       at System.Windows.Controls.ScrollViewer.ExecuteNextCommand()
       at System.Windows.Controls.ScrollViewer.OnLayoutUpdated(Object sender, EventArgs e)
       at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at Ellipse3DLayoutTestapp.App.Main() in D:\WPF\Dicomv\Ellipse3DLayoutTestapp\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:


please please provide me the answer for this.

推荐答案

有关更多详细信息,您可以在此处粘贴完整版本代码(XAML和C#)吗?
您可以使用编辑器右上方的插入代码块"图标.
然后,我可以编译您的程序并尝试添加您所要求的功能或功能.
For more detailed information, can you paste your full version code (both XAML and C# ) here?
You can use the "insert code block" icon on the top-right of the editor.
Then I can compile your program and try to add the function or feature you have asked.


这篇关于例外:无法在“空白矩形"上修改此属性.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆