Guidance on M-VC with User Controls

S

Steve

I was fine with my typical event driven structure of my app (IE: User
Clicks "Delete Item" button, the event fetches the Business Object from the
selected TreeNode's Tag property and calls the Business Object's Delete()
method. I would then update the tree somehow to reflect the deletion of the
item. This worked fine.

I have since made extensive use of UserControls and find that I don't have
such easy access to my other controls in the Form class. For example, if my
"Delete Item" button resides in a UserControl, I know need to make my
UserControl aware of the Form class and further, I need to either make my
TreeView public or add a property. This just seems problematic and bad to
me. It made me rethink my design and search for a better solution.

I am no WinForms veteran, so I don't know what my options are. The MVC
pattern sounded nice at first, but I'm not convinced it will help me out.
What I'm interested in is a framework that will allow my UI to work with the
Business Data or "Model" and easily elegantly keep the UI in sync with the
Business Objects. IE: If I delete a business object, I want to reflect
that in the UI.

I hope I am not too vague.

I'm contemplating routing ALL non-view operations through the Model class.
So rather than get the Business Object reference in the event handler and
call the member function, I would instead call a Model method like
"DeleteItem" and let it get the currently selected tree node, call it's
Delete() method and finally update the UI.

Problem is, this is both decoupling the Business from the UI while at the
same time tightly linking the UI to the business. I just don't know.

Anyone want to be kind and guide a newb ;)

Thanks for reading,
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top