如下图所示。
class LayoutPreviewBarWindow : DockableToolbar, BMG.IGuiDockable { #region 单例 static private LayoutPreviewBarWindow _layoutPreBarWindow; #endregion private LayoutPreviewBar _bar; public LayoutPreviewBarWindow() { _bar = new LayoutPreviewBar(); _bar.VerticalContentAlignment = VerticalAlignment.Center; this.Content = _bar; this.Title = "LayoutPreview ToolBar"; this.AttachingToHost += new BMG.AttachingToHostEventHandler(Window_AttacthToHost); this.DetachingFromHost += new EventHandler(Window_DetachingFromHost); this.Attach(SubgradeNET.Instance(), "SubgradeNET"); //Setup AutoOpen after calling Attach() this.AutoOpen = true; this.AutoOpenKeyin = "mdl silentload subgradeNETUI,,DEFAULTDOMAIN;SubgradeNET CrossAidedDesign LayoutPreviewBETA"; }
这个我记得是窗体类实例作为一个控件添加到Mstn管理的窗体中了,在父窗体Resize的时候,子窗体也就是您这里的LayoutPreviewBarWindow的位置(Location属性)没有边导致子窗体跑到可现实范围外造成的,您试试监听一下Resize事件(重写的IGuiDockable的WindowMoving函数),在事件函数中去设置一下子窗体的Location属性。
您好,LayoutPreviewBarWindow没有Location属性,继承自DockableToolbar,没看到Location的属性;
请改为下图所示的方式去调用窗体。
两种自动加载的方式,效果一样。
我把Location不设置为(0,0)就可以了。给了一个(1,1),就可以正常加载了。
不需要设置Location的,我前面说的需要设置这个值是在使用DockableWindow去实现可停靠窗体时才会有这个问题。例如这个贴子中的问题:【MSCE C#】开发WPF继承于DockableWindow的窗体时,如何获取窗体移动时执行代码
是的,我一开始没有设置,用keyin加载正常,ORD启动并自动加载异常。
把location给一个不为0,0的值,keyin正常,ORD启动自动加载正常。