Why is it ok to use the view's logical name in PRISM View-based Navigation? - mvvm

So I'm a complete newbie to PRISM and just trying to get my head around all the concepts, one of which is Navigation. I have separated all my views into separate modules (along with their vm's) and now I need to be able to switch between them.
Apparently I need to use RegionManager.RequestNavigate and pass in the view's logical name. I'm just wondering how this is meant to be decoupled as the modules now know about each other (even if just it's just by name). So if I decide to make a change or use the module in another project it's not going to work anymore.
Unless I've totally misunderstood this.

I think the idea is that while you must have a view name to navigate with, that is all that needs to be known. So if I have 'StockViewer' as a view, I could drop any 'StockViewer' module in, and the other applications would be none the wiser that they are at all different.
For me, I basically created a NameService of sorts, that I can call and have an object representation of names, so I don't fat-finger a name and spend hours trying to troubleshoot why something didn't load.

Related

How to to reuse content between two DITA maps and keep the folder structure

I am using Oxygen XML Author and I have two maps that have a lot of similar content. Right now, the content is not reused, but it would be great to make it reusable. The maps are called InstallGuide.ditamap and AdminGuide.ditamap they are stored on the disk with the following hierarchy:
common/
InstallGuide.ditamap
Product/
ProductFeatures/
MainProduct/
AdminGuide.ditamap
Is there a way to put a new parent map to disk root and include my other two maps in it and make content reusable? Right now if I try, the maps are included, but only as non-editable references so I can't set up any reuse and can't set profiling attributes.
Why do I need profiling?
Since the maps are two different documents I want to be able to profile them from the parent map. But I want to also be able to reuse content from one map to another. Moreover, I would want to keep the folder structure unchanged. Is that possible?
I can't get my head around the solution for my "wants". Maybe someone can propose a better way to achieve the goal, I would appreciate that.

Is my thinking about mvvm right?

I'm having a little bit of a hard time getting into mvvm. I'm writing a simple app, Notebook. I have one viewmodel, it's name is actually ViewModel. It has an ObservableCollection of Notes inside and methods to save and load those from Isolated Storage. My only Model is Note.cs, it implements INotifyPropertyChanged and I'm of course RaisingPropertyChanged.
I've also got two view, both of them are user controls. One to display list of notes and one to edit the one chosen from the list.
My questions are:
Where do I create an instance of my vievmodel?
How should I implement going from the page with list of notes to the page with detailed view after choosing one Note to edit? At the
moment I'm saving the index of Note in App.xaml.cs, going to the next page and setting
the DetailedView DataContext to the right Note in OnNavigatedTo, but
I don't think it's actually the perfect solution.
Where should I save my Notes? I guess Application_Closing in App.xaml.cs is the right place to do it, but I'd have to have my viewmodel as a global object there, is this the right approach?
Additional question:
I have to add possibility to group notes. I guess that class Group with dictionary (GroupName, howManyNotes) is going to be allright since I don't have to be able to for example write all notes from selected group. Do you think there's a better approach I should think about?
Thanks for respones,
MichaƂ.
I would suggest you take a look at Calibrun.Micro which is a great framework for MVVM. You can get some sample from the CodePlex.
I have used that in a bunch of Project, and will give you flexibility in case if your project grows in size.
Google for Caliburn.Micro sample and you will find a number of sample for all technologies like WPF, Silverlight, Windows Store, Windows Mobile.
Caliburn.Micro CodePlex

Two very similar apps, with different texts and UI graphics

I'm going to developer two very similar apps, the logic is absolutely the same, but api calls base URLs, texts and UI graphics( such as backgrounds etc) will be different, but the all views will be the same (buttons, labels in the same places). It's quizes apps.
How to do it in the smart way? To not duplicate code etc.
I thought about to setup workspace, add bundles with UI, plists with texts and URL's, and than based on project name or identifier use one of the bundles, etc.
Maybe somebody can share smth else? More efficient way.
Thx.
I thought about [...] adding bundles with UI, plists texts and URL's
You wrote your own answer. Additionally you setup two targets. One for each project. Within the target you define an envorinment variable, which you can use in your code to switch between the bundles / URLs.
You should write a Helper Class to get the Ressources. That helper class checks the environment variable and gives back the correct ressource.
(You may want to write categories for UIImage and NSURL and write your own NSLocalizedString version. With that you don't need to check any conditions/settings anywhere else in your code.)

Is it bad practice to handle the showing of the open file dialog, and other dialogs, from within a custom textbox control?

I am making a custom textbox control and am thinking about adding keybindings in the constructor that execute commands to open and save files. I am also thinking about handling the find and replace dialog from within my textbox control.
Is there a reason I shouldn't do this?
--Edit--
I am planning on only using this control in my current application. One of the reasons I am thinking of doing this is to avoid binding to the textbox's Text property, since this binding seems like it would be just as inefficient as updating a string on the textbox's textchanged event.
Well, flexibility comes to mind. Consider the following scenarios, which would be impossible (or at least difficult) in your control:
You want to handle multiple or different methods of opening a file, but it depends on your application.
You want to use your textbox but limit the functionality -- e.g., Find/Replace is not allowed.
You want to change the behavior of any of that in one application but not the other. For example, in app A you want to tack on an extra slash to the end of the text, but in app B you want to add a custom folder name.
In general, I would consider something more generic. Something like a textbox has a specific purpose; enhancing that purpose is fine, but you're going beyond that. You're taking logic that rightly belongs to the app and putting it on a specific control. That limits what you can do with the control across multiple apps.
Of course, if you're writing a control specifically for one and only one app, you don't need to worry about these things. But I would still consider it a bad practice, myself.

GWT Lazy Loading

I want to develop a GWT application. The application contains 8 modules and all the modules run in a single page.
I have links for all the 7 options on the top.
When the page loads I want only the home content to be loaded and displayed.
Only when the user clicks the menu options, the menu content should load.
Can anyone suggest the best way to achieve this.
This has been addressed in GWT 2.0... First you'll remove the separate entry points you have for each module - since they're all on the same page, you only need one entry point per page.
Then you can use the GWT.runAsync() method at each point that you feel can be a split... it automatically cuts up the code into chunks that are downloaded as and when necessary.
Look here for the docs.
AFAIK, lazily loaded (or pluggable) modules can't be done in GWT. Partly this is due to the way the GWT compiler works - it likes to import all the code that it is ever going to see and then optimises and prunes it as viciously as possible (to make the resulting JS files as small and lead as possible). If it doesn't have access to all the source code up front, it might make optimisations that will break the pluggable modules (especially since nothing in the "core" application may reference the classes that the lazily-loaded modules need to work properly - the GWT compiler would prune those "unused" classes in the core module).
This stackoverflow question from May 09 asks the same thing and has the same answer - it can't be done.
I searched high and low about six months ago for an answer to this problem, because I really wanted to do what I believe you're asking for. Never found a solution.
(I haven't used GWT 2.0 - it might have addressed the issue)
Thank you for your answer. You are right that the whole Javascript code gets downloaded.
But there must be a way like say on of module is View Profile. Only when the user clicks the view Profile link, the widgets related to displaying my profile needs to be created. is this not possible.