New Posts New Posts RSS Feed: [COMPLETED] Widget View Template
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[COMPLETED] Widget View Template

 Post Reply Post Reply Page  <1234>
Author
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Topic: [COMPLETED] Widget View Template
    Posted: 21-Sep-2007 at 5:45pm

It works with a GridView because Ward has implemented a "GridViewToolStripAdapter" (an abstract class in IdeaBlade.Cab.Interface/Miscellaneous) and the concrete class DotNetNavigatorGridViewToolStripAdapter (in IdeaBlade.Cab.UI/Miscellaneous).

This is used by the GridViewPresenters to allow the navigation tool bar to manipulate the view's binding source.
 
Despite the name, there is very little in these classes that is dependent on GridViews  (The main thing that I see is a dependency on the ViewContext being a GridViewContext).
 
I'll talk with Ward about how this is implemented, but I'm afraid this is a case where we've provided a working example of how to do something, but it's up to you to replicate it for a different scenario.
 
Another option:
 
Rather than following this pattern and making the navigation tool strip part of your control view, you might follow my LayoutDemo pattern and create a layout view with a tool strip and a single SmartPartPlaceholder.
 
Its controller (a TabViewController if it's going in a TabWorkspace) would get the binding source from the child view context and hook it up to the navigator.  (Use reflection to see if the child view context implements an interface (call it "IBoundContext").  If so, get the binding source through it and hook it up to the navigator.  If not, hide the navigator. 
 
Then simply make your control view use a special context object that implements IBoundContext and supplies its binding source.
 
I haven't tried this, but is seems like it should work.
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2007 at 9:55am

Thanks for the direction!  I am working on implementing a new ControlViewToolStripAdapter.  The context thing is a bit cryptic to me but I am making headway.  I am going to try to make the adapter dependent on the ViewContextBase rather than the GridViewContextBase.  I should have something going by the end of the day.  If not, I'll pop in more questions here.

Again, thanks!
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2007 at 3:26pm
The following are the items that I have created in an attempt to duplicate the toolbar adapter in a loose control view context:
 
IdeaBlade.Cab.DevEx
  Views
    Base
      DotNetControlViewWithToolBar.cs
IdeaBlade.Cab.Interface
  Miscellaneous
    ControlViewToolStripAdapter.cs
  Views
    Base
      ControlViewContextBase.cs
      IControlViewWithToolbarPresenter.cs
IdeaBlade.Cab.UI
  Views
    Base
      ControlViewContext.cs
      ControlViewWithToolbarHelper.cs
      ControlViewWithToolbarPresenter.cs

    Widget
      BasicControlViewWithToolbarPresenter.cs
 
MyApp
  PageControllers
    ContactsViewTabViewController.cs
  Views
    ContactsView.cs
    ContactsViewPresenter.cs
 
So far, my efforts have resulted in white screens of death in the VS IDE.  Something is not quite right with linkage between the actual view in my app and the helper class in the IB.CAB.UI project.  Not sure if I have learned how this all works, yet.  I'll keep working on it.  I'm sure that I have not thrown the right switch somewhere.
 
More docs on how this stuff all works together would be great.  I think someone said there were some in the works.  Not only would a doc that states what is inherited from what, but the whys and wherefores would be excellent to have, too.
 
Bill
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2007 at 3:38pm
I agree, this seems like a complex solution to me.  If it gets too deep, you might try the alternative of creating a layout view with a binding manager and a single SmartPartPlaceHolder, then hosting your control view within that.
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2007 at 4:22pm

Soooo close.

I was going to paste an image here, but the forum has blocked me from uploading.  It states that I do not have sufficient privileges.  Oh, well.
 
What I have gotten is my view loads in the tab detail area of the SearchMasterDetail page.  I can see the binding navigator in full living color!!  Now, I just need to get my designer to quit hollering at me about the helper class.  I'll post more here shortly once I figure out why this class is not getting called properly from the designer.  And, I can get my data to show up.
 
Almost there.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2007 at 5:19pm
Just in case anyone can help, here is the error that I get when attempting to open the ContactsView.cs in Design view:
 
X One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.

Could not load type 'IdeaBlade.Cab.UI.Views.ControlViewWithToolbarHelper' from assembly 'IdeaBlade.Cab.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Hide    

at IdeaBlade.Cab.DotNet.DotNetControlViewWithToolbar..ctor()
 
I did try the normal rebuild/debugging routines.  The one thing that I did not try was the close/reopen VS thingy.  I will try that and let you know if that worked.  There has been issues in the past where VS didn't renew its cache or something.  Stand by.


Edited by Linguinut - 24-Sep-2007 at 5:21pm
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2007 at 5:39pm
Yup...the ugly VS cache was rearing up again.  Closing/reopening the solution did the trick.  I got to stop thinking it was my fault and try that first next time.
 
Anyway, now I have the data showing up (because I can now bind some controls); however, the toolbar is inactive.  I think there is a switch in there somewhere, but it is time to go home.  Maybe tomorrow I'll be able to wrap this up.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2007 at 9:45am

I cannot get the toolbar enabled.  I do not know where to throw the switch.  Data is showing up on the view in the tab control.  I can update the record that I am on (both customer and contact).  I just cannot see more than one contact because the navigation is disabled.  Where should I enable the toolbar?

Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2007 at 10:58am
Have you checked that the BindingSource for the ControView is properly assigned to the BindingSource property of the BindingNavigator.
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2007 at 1:01pm

Ugh!  After all that work yesterday, I think I really screwed up the LIB source projects.  I added a ControlViewWithToolbarPresenterBase class in order to replicate what was done in the GridViewPresenterBase class. For the life of me, I cannot get the ViewContext to behave in the following method of the presenter class:

protected override ControlViewToolStripAdapter SetControlViewToolStripAdapterCore(object pToolStrip)
{
    return new DotNetNavigatorControlViewToolStripAdapter 
         (pToolStrip
 as BindingNavigator, BindingSource, ViewContext);
}
 
It is looking for the type ControlViewContextBase.  It is in the presenter base class.  That type is being returned as ViewContext.  And, it should be available to this presenter.  Yet, it ain't happenin'.
 
Time to take a walk.  Maybe it will all fall into place after I clear my head a little.
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2007 at 2:03pm
I'd like to help, but I don't quite understand the problem.
 
What do you mean when you say you can't "get the ViewContext to behave"?  Do you get a compile error?  An exception at runtime?
 
Are you calling SetControlViewToolStripAdapterCore() after the context has been set in the presenter?
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2007 at 2:13pm
The ViewContext is showing up as an IBindingViewContext type rather than the expected type of ControlViewContextBase.  The presenter base class has the following:

///
<summary>Get the ControlView's ViewContext.</summary>
protected new ControlViewContextBase ViewContext {
    get { return (ControlViewContextBase) base.ViewContext; }
}

/// <summary>Get the view's ViewContext.</summary>
IBindingViewContext IControlViewWithToolbarPresenter.ViewContext{ get { return ViewContext; } }

This is setup in the same way as the grid view presenter base class.  I tried to force the type by casting it; however, that did not work.
 
I am not sure if SetControlViewToolStripAdapterCore() is called after setting the context.  I will set some breakpoints to see if the calls are being made in the proper order.
 
 
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2007 at 2:34pm
I found an override where one didn't need to be.  It was in the ControlViewWithToolbarPresenter class. 

///
<summary>get the view's bindingviewcontext</summary>
public new ibindingviewcontext viewcontext
{
    get { return (ibindingviewcontext)base.viewcontext; }
}
 
I commented this section out.  Now, I am past that error, but am now experiencing another.  A similar error so I will review all of the various pieces again and see what I overlooked.  It is not easy converting from the grid view to the control view.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2007 at 3:20pm

Unable to cast object of type 'IdeaBlade.Cab.UI.ControlViewContext' to type 'IdeaBlade.Cab.Interface.ControlViewContextBase'.

This is being thrown on:
/// <summary>Get the ControlView's ViewContext.</summary>
protected new ControlViewContextBase ViewContext {
    get { return (ControlViewContextBase) base.ViewContext; }
}
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2007 at 5:01pm
So...
 
does IdeaBlade.Cab.ControlViewContext inherit from IdeaBlade.Cab.ControlViewContextBase?
 
Neither of these are defined in standard IdeaBlade.Cab.  The ControlView is built using BindingViewContext.
 
What are you adding in ControlViewContext (and CVCBase) that isn't present in BindingViewContext?
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2007 at 5:18pm
It is very difficult to present to the forum all of the intricacies of this project.  As a result, I have obviously not provided enough information about what I am doing.  Sorry about that.
 
I didn't have any kind of support for the toolstrip in the BindingViewContext, so I created a new one--ControlViewContext.  I threw a few things in there to get the ball rolling.  It is possible that I didn't need to do that.  I am attempting to get this current casting issue resolved and it may include rewritting some of those classes.
 
As I was finishing this response up, I did notice that ControlViewContext was inheriting directly from BindingViewContextBase.  I changed that to ControlViewContextBase.  Building now.  Will test shortly.
Back to Top
 Post Reply Post Reply Page  <1234>

Forum Jump Forum Permissions View Drop Down