Vertical scrollbars

Hi,
I am currently evaluating the controls for WPF. Things are going pretty well, but I have 2 issues that I can't seem to get around.
1) How do I get the ability to work with a diagram that is taller tan my viewport? No matter what I do, I can't get a vertical scroll bar to appear. The size of my nodes is limited to whatever height I have. This includes zooming. I can add nodes horizontally as much as I want. But for every row vertically, the nodes get smaller.
2) I tried to play with the overview control, but whenever I have one defined in XAML, my form gets an error and will not display. Here is the XAML,
<go:Overview x:Name="SponsorOverview" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Background="WhiteSmoke" />
Here is the error I get

Exception has been thrown by the target of an invocation.

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Delegate.DynamicInvokeImpl(Object[] args) 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)

If I ignore the error and run the app, the overview control kinda works in that clicking arounf it will scroll the diagram, but nothing is drawn in the overview contriol except the selection box which is sometimes really small and narrow.
I have added the statement SponsorOverview.Observed = dg;
at both the constructor, and after I constructed the diagram and added all the nodes.
Thanks.
  1. That’s an odd problem, since it requires work to get the behavior you are seeing, and what I think you want is the default behavior.

Have you set the Diagram.Stretch property, or DiagramPanel.Stretch? Perhaps to the value UniformToFill?

Have you supplied your own ControlTemplate for the Diagram? In the standard ControlTemplate the ScrollViewer has the attribute VerticalScrollBarVisibility=“Auto”.

Have you set DiagramPanel.FixedBounds?

  1. Can you get any more information about the exception?

Yes, you need to set the Overview.Observed property after both Diagrams have been loaded. Perhaps if you remove that assignment from the constructor and put it into a window/page Loaded event handler?

I had created a new TreeLayout for the diagram and set the Diagram.Layout to it. I think that’s the correct way to do it. I then had the angle set to 90 to have it flow from top to bottom. Per your suggestion, I then set the new tree layout Diagram.Stretch to StretchPolicy.None and it then worked as I wanted it to. After looking at my XAML, i had the stretch property set to UniformFill on the diagram. Thanks for that.

The only other info about the exception is a commit transaction. This occurs by simply adding the overview control to the window.

CommitTransaction must have a non-null Diagram.Model

at Northwoods.GoXam.Diagram.CommitTransaction(String tname) at Northwoods.GoXam.LayoutManager.#Ed()

Here is my XAML that adds both controls. They are 2 consecutive lines. (I am removing the Stretch property. )
<go:Diagram x:Name="dg" Grid.ColumnSpan="1" NodeTemplate="{StaticResource DataTemplateMemberNode}" Stretch="UniformToFill" Margin="5,3" Background="#FFDDF6C2" /> <go:Overview x:Name="SponsorOverview" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Background="WhiteSmoke" />

OK – as it turns out, that error message has been removed in version 1.1, because it was deemed to be too careful.

It’s a plausible error message – every Diagram ought to have a Model – but it’s a problem when dealing with odd initialization circumstances. So CommitTransaction will just be a no-op in such cases in v1.1.

So if you change your initialization code to happen only at Loaded time, does it show properly for you?

So are you saying that I should only add the overview control in code after the window is initialized and loaded, and not in XAML? Also, the overview control does function in the app despite the above error. But I have never seen the overview of my diagram on the overview surface, just the selection box which does track with the mouse.

No, you can leave the XAML the way it is – it’s just the setting of Overview.Observed that I think might help to be executed after both the Overview and the target Diagram have been loaded.

I think you misunderstand. Simply by having the following line defined

<go:Overview x:Name="SponsorOverview" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Background="WhiteSmoke" />
generates the CommitTransaction error in the design preview window in VS2008 and Expression Blend. I don't need to run the app. As soon as I comment the line out, the preview window then will display my stuff. If I then ignore the error and run the app, the app runs without error, and the overview control works, i just never see my diagram in it, just a white background with the demo message in the middle.

OK, but when is that Overview.Observed assignment taking place?

In other words, does either problem occur when it only happens in a Loaded event handler?

I did some more experimenting. What I found was that if I have the statement in the window constructor, the overview works but I don’t get an image. If I move the assignment to the loaded event, I get the image and it works. If I move the statement after the loaded event, but before I populate the diagram, I get the following error before my app even displays the main window

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
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 GoSponsorTree.App.Main() in D:\Current DotNet Development\2008\Framework 3.5\CSharp\GoSponsorTree\GoSponsorTree\obj\x86\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()
That does go away when I put the statement in the load event, so it's no big deal. However, I still can't get rid of the error in the design window. I think that's now my final problem.
Thanks

OK, I’ve made that v1.1 change to the v1.0 stream. You can get the DLL from the post: http://www.nwoods.com/forum/forum_posts.asp?TID=3038

That took care of the problem. Thanks for all your prompt help.