|
-
Jan 1st, 2010, 03:30 PM
#1
Thread Starter
Frenzied Member
Passing an object by refrence to multipule UI controls
Hi Guys,
I just wanted to know if this is the correct way of doing this. I have a utility that takes the for of a wizard. There are five pages to this wizard and each page tends to need data that is selected from the other.
The way I was intending on doing this was to create an object that would hold all of the needed data and pass it by reference to each page as this means that I only need one object to track all of the data. Is this the correct way of doing this or am I going about it the wrong way?
-
Jan 2nd, 2010, 02:44 AM
#2
Re: Passing an object by refrence to multipule UI controls
Just to be sure, by a page you mean a web page and not window form?
-
Jan 2nd, 2010, 01:46 PM
#3
Thread Starter
Frenzied Member
Re: Passing an object by refrence to multipule UI controls
Actually they are WPF pages but function somewhat like ASP.NET pages in so far as you navigate to a page as opposed to opening a window!
-
Jan 2nd, 2010, 09:24 PM
#4
Re: Passing an object by refrence to multipule UI controls
I'd be inclined to use a singleton, which negates the need to pass the object from page to page.
-
Jan 2nd, 2010, 11:09 PM
#5
Thread Starter
Frenzied Member
Re: Passing an object by refrence to multipule UI controls
I've always been told the singleton pattern is not good design wise but in this case I suppose it makes sense. I seem to run into this issue quite a bit lately, it is hard not to be brittle with regards to UI coupling as I find there is only so much that can be abstracted out of the UI class itself.
-
Jan 2nd, 2010, 11:22 PM
#6
Re: Passing an object by refrence to multipule UI controls
Using a singleton won't really be any more brittle than passing an instance of a class from page to page, assuming that you're passing it as it's actual type. If you're using an interface rather than a concrete type then that does become more robust. If you really want to follow good design principles in WPF then you should probably research the MVVM pattern, which is pretty much the new MVC/MVP for WPF.
-
Jan 2nd, 2010, 11:37 PM
#7
Thread Starter
Frenzied Member
Re: Passing an object by refrence to multipule UI controls
That's a lot of acronyms!
I agree a singleton makes sense, there is not a lot of data, the application is small and there is no expansion, it does what it does and singularly. As for the other patterns I have never heard of them so I will have to look them up.
This thread makes me wonder though is the issue more about bad layout. I had assumed that the best way for a wizard style application or one that follows a singular logical layout should have a global object to store the needed data as it pulls it from the pages. In my head this made sense as it was the only way I could see that the data could be retrieved.
I thought it was a simple issue of passing values back to the caller but because each page opens the next the caller is the previous page and not the application. Hmmm, UI's certainly make programming harder!
-
Jan 2nd, 2010, 11:49 PM
#8
Thread Starter
Frenzied Member
Re: Passing an object by refrence to multipule UI controls
Ok, had a look over the MVVM and honestly I only understand it in high level so I think im going to take a few days to pour over this and research it a bit more!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|