Universal app with PCL - navigate to proper View - windows-8.1

I have question whether it is possible somehow use this project structure and within some ViewModel navigate to specific View from Core.Windows/Core.WindowsPhone.
1. PCL libraries
Core (PCL for universal apps)
ViewModel
Core.Windows (PCL) - reference to Core
View
Core.WindowsPhone (PCL) - reference to Core
View
I need to keep View in PCL because I use the same View for some other projects.
2. Universal app
Windows - reference to Core, Core.Windows
WindowsPhone - reference to Core, Core.WindowsPhone
Shared

Yes I think it is possible.
I have a similar requirements in my solution (using same View for different apps)
Basicly I suggest the following:
1) Create a NavigationService abstract class and/or INavigationService interface in Core (PCL for universal apps with ViewModels).
2) Create WindowsNavigationService and WindowsPhoneNavigationService classes in Core.Windows and Core.WindowsPhone which derive from NavigationService in 1)
This classes can do the following:
1) Hold an instance of
Dictionary<ViewModelBase,Page> mapDictionary
ViewModelBase is a base class for your viewmodel (I suppose you have one).
2) Register the data in mapDictionary: e.g. add View and corresponding ViewModel to it
3) Perform navigation buy holding the instance of Frame: e.g. NavigateTo, GoBack and so on
4) Bind the ViewModel to View.
After that you can Hold a NavigationService in your ViewModels and perform navigation between them.
If you are interested in such approach I suggest to waste some time and take a look at https://github.com/MvvmCross/MvvmCross - this can give you ideas about how you can build your architecture.
Also interesting post about PCL (with sample code demonstrating described approach): http://msdn.microsoft.com/en-us/magazine/hh852593.aspx
Source code for the article: http://download.microsoft.com/download/6/2/D/62D36C65-4C36-429A-8711-F657D34AB4BC/Code_KeanPCL0312.zip

Related

Using a iOS UITabBar with MVVMCross MvxViewController not MvxTabBarViewController

We have a 4 views that are considered siblings in the UX design and so we would like to display them on a TabBar in iOS. We already have them in a NavigationDrawer in Android.
Lets call them
Customer
CustomerOrders
CustomerHistory
Returns
These are represented by 4 separate ViewModels. Looking at the MvxTabBarViewController samples I have to created a Uber ViewModel that exposes all 4 ViewModels as properties. Then attach the 4 views (MvxViewControllers) to a Parent View (MvxTabViewController).
UPDATE
I don't want to create a ViewModel just to support iOS' way of doing things.
I tried creating a UITabBar as a standalone view but that fails to deal with more than 5 items.
I have given up trying to fight the toolbar and am going to create a iOS specific ViewModel to host the Customer, CustomerOrders, CustomerHistory and Returns ViewModels. That is how the MvxTabViewController wants me to do it so I will. Getting that to work involves some MVVMCross configuration that I think is best handled by a new question. Once created I will link to it from here New question
Any suggestions?

In VS2012 how do I filter the Object Browser to display objects in my Project?

In VS2012 how do I filter the Object Browser to display objects accessible from my Project?
As far as I can make out from the UI it can be configured to show either
1) Everything installed on the machine.
2) A manually selected subset of everything installed on the machine.
3) Everything referenced by the entire Solution.
So where is the most useful view of all, namely the view of everything referenced by the current Project?
The MSDN even states that you can use it to view what can be referenced by the Project
http://msdn.microsoft.com/en-us/library/vstudio/exy1facf%28v=vs.100%29.aspx
"The Object Browser lets you select and examine the namespaces, classes, methods, and other programming symbols available for use in your project."
But I can't see how to do it.
You can use the Class View (Ctrl + Shift + C) to see the references available per project.
Look in the Projects References section of each project in the Class View.
Example: Class Library in Solution
Here, I am looking at the System.Collections classes.
Example: WPF Project in Solution
Here I am looking a the System.Diagnostics classes
To view the class in Object Browser, right click and choose, "Browse Definition".

Insert a Monogame view inside MvvmCross monodroid Activity

I'm trying to build a Monogame view inside a RelativeLayout from my MvvmCross monodroid Activity view.
An android Activity inherits from Microsoft.Xna.Framework.AndroidGameActivity to be able to run a Monogame inside a RelativeLayout (working).
My MvvmCross Activity inherits from MvxBindingActivityView(working).
So, I need a way to run the game and bind some datas within the same activity.
Thanks in advance for your help.
Loosely speaking, you can translate any Activity to an MvxActivity by inheriting some interfaces and by then cutting and pasting a small amount of code which does the basic loading and assignation of the ViewModel.
e.g. see the #Region and IMvxAndroidView<TViewModel> added to make MvxActivityView.cs from a normal Activity.
e.g. it's the same region and interface used for adapting a specialised Activity like Google's MapActivity into MvxMapActivityView.cs
At this level, the Activity/View has a ViewModel which can be used in C# code, but has no clever xml inflation - it has no clever Binding support.
Code can be written at this level - I've shipped apps without binding - but many users prefer to add DataBinding too...
To add this DataBinding support, you need to add a bit more code which provides BindingInflate, storage of bindings, disposal of bindings, etc.
e.g. a raw MvxActivityView is extended using the IMvxBindingActivity interface and a #region like: MvxBindingActivityView.cs
e.g. MvxMapActivityView is extended using the same region and interface: MvxBindingMapActivityView.cs
So to extend your the custom AndroidGameActivity:
Inherit from AndroidGameActivity to get ViewModelOwningGameActivity<T> and cut and paste the IMvxAndroidView<TViewModel> interface and #region from MvxActivityView<T> to provide the ViewModel methods, fields and properties.
Then assuming you want binding:
Inherit from ViewModelOwningGameActivity<T> to get BindingGameActivity<T> and cut and paste the IMvxBindingActivity and #region from MvxBindingActivityView<T> to get the binding methods
For specialist Activities you may want to add more - e.g. you may could add some custom helper methods for the MapActivity to plot points and lines, or for GameActivity to do whatever games do... but this is up to individual implementations.
Sorry about the cut and paste of code required in adapting Activities - I have tried to keep this to a minimum. However, writing Mvx is the one time so far that I've really wanted Multiple Inheritance or Mixins in C#

developing library controls for xpages

I' working on a library control for Xpages and need some help in creating.
I would create a control which reads a configuration file and creates controls in a table, controls like Editboxes, checkboxgroups and so on.
so and now to my questions:
could I initiate controls from the Exlib or must I implement them all by my self?
if I could use them from the Exlib could anyone explain me how?
I hope its clear what i mean if not please ask me for further informations.
When creating your own components, if you're closely replicating some behavior that is already in an extension library component, I highly recommend you extend that component and just add what's needed to accommodate your different functionality. This makes things much easier and you don't have to code around every little scenario that the component might be placed in.
But, if you are developing a component that is nothing like any of the extension library or core components then just ensure your component extends UIComponent or UIComponentBase. If going this route, you'll also need to create your own renderer which extends Renderer. This is what will build the on-screen representation of your component. Again, if there's already something in the core components or extension library components that closely mimics what you need then make your renderer extend that renderer. Also, don't forget to include the renderer definition in the faces-config file and the component definition in the xsp-config file or your component won't work.
As for initiating controls from the extlib.... I assume you mean can you inject them onto the page at runtime. If so the answer is absolutely yes. To add an input text field to the page where there is a container (i.e. panel, div, span, whatever) with an ID of "someContainer"
XspInputText input = new XspInputText();
input.setValue("someValue");
input.setId("someID");
UIComponent container = FacesContext.getCurrentInstance().getViewRoot().findComponent("someContainer");
container.getChildren().add(input);
To see the api for all of the core and extension library components take a look at the XPages Controls Documentation. For a more complete tutorial on creating your own components take a look at my blog for creating a custom component inside an nsf, the steps are pretty much the same for putting them into a library:
Part 1,
Part 2 and there is an example database in the Part 2 post.

MonoTouch 5 Error: "Failed to find selector setXxxxxx" after migrating to Xcode 4.2 and MonoDevelop 2.8

I have an iPad project that has been under development in Xcode 3.2.6 / MonoTouch 4.2.x / MonoDevelop 2.6 and when I installed the Monotouch 5, MonoDevelop 2.8.1 and Xcode 4.2 the project compiled and run OK. But when I started to change the XIB files in Xcode 4.2 (adding outlets) I started to have some glitches:
1) App crashes and MonoDevelop in debug mode says the the views were not loaded because the view outlet was not set. I figured out that in Xcode 4.2 there is no need to create an outlet named "view" in the .h file and just need to connect the File Owner view to the view control in the designer. Correct?
2) The main problem and is not solved yet is that I get exceptions "Failed to find selector setXxxxx" where "xxxxx" is a name of an outlet for a UI control. It started to happen in ViewControllers that inherited from a base view controller, but as soon as I started to change other normal viewControllers I get the same type of errors. Any hints of what is wrong?
3) I have a controller that loads dynamically some views and that works fine. but when I set a property on one of this sub views outlets (like the Text of a UILabel) the value is set (on the debugger) but no change in the UI. The actions for example work fine. What could be wrong.
4) Any special settings in the XIB's that are needed in order to correctly under Xcode 4.2 to integrate well with MonoDevelop 2.8?
Help is much appreciated, I thought in going back to the previous set of tools and monotouch but I guess once the project was upgraded there is no way to go back without losing all the development done now.
Thanks, Pedro
EDIT: Beside the new clean attributed [Outlet] code generated by MonoTouch 5 (replacing lot of code previously generated), the significant difference is that before the partial class generated was public and now is private, this may be the source of my problem. Is there a way to generate public partial classes or protected?
EDIT 2: If I manually add the public keyword to the partial class and members generated by MonoTouch in designer.cs the selectors are generated behind the scenes and all works. This indicates that with the change from public to private partial class the bindings generation changed in MonoTouch 5, is it by design or bug? I would find it very strange that now its not possible to create a viewcontroller with outlets, subclasss it and the child viewcontroller cannot access the parent class outlets.
1) There is indeed a view outlet on the base UIViewController class, which is an Objective-C property. When using Interface Builder 3 with MonoTouch, IB often didn't allow connecting to the base view outlet so many users created their own in their custom subclasses. MonoDevelop 2.6 and older created these custom outlets as ivars (Objective-C fields), and apparently the UIKit runtime would connect the object to both versions of the outlet - both the custom ivar and the base property. MonoDevelop 2.8 generates the custom outlets as properties, which means that the redundant view outlet shadows the base view outlet, so the base view outlet is never set, and UIKit gets unhappy. You can fix this by removing the redundant custom view outlet - MD 2.8.2 will do this automatically.
2) Seems to be a bug with the way MonoTouch exports custom outlets that prevents connecting to custom outlets defined in base classes. A possible workaround is mentioned on the bug report.
3) The UI rendering won't update while your app is paused in the debugger, it'll update on the next mainloop iteration.
4) Nope.
5) The class accessibility should be controlled by the user class part, not the designer class part, so you can freely change it.

Resources