Tabbed navigation using mvvmcross and xamarin forms - tabs

I am trying to create tabbed app using mvvmcross and xamarin forms, but I can not get rid of main Navigation(Title) bar. I did research and if I have got it right, I will have to create my own presenter. I base my oppinion on this link.
https://github.com/MvvmCross/MvvmCross/wiki/ViewModel--to-ViewModel-navigation
Site redirect me to article "Presenter roundup". Unfortunately I couldn't figure out the solution.
My problem looks like this
Thanks for response.
PS: While answering please keep in mind that I am new to Xamarin and MVVMCross :)
Edit 1:
public class App : MvvmCross.Core.ViewModels.MvxApplication
{
public override void Initialize ()
{
CreatableTypes ()
.EndingWith ("Service")
.AsInterfaces ()
.RegisterAsLazySingleton();
RegisterAppStart<ViewModels.TabbedViewModel> ();
}
}

Related

Adding API's to chromium build in Electron framework

I would like to write custom functions in Window API in chromium source code. So how do we do it?
In case of doubts about window API here's a link to what I mean click here. I would like to have custom property functions analogus to those shown in the link.
It's for a github electron project.
Well after a week of searching I finally found the solution. Thanks to a pull request by magicae#github.
You need to look create your custom function in
electron/atom/browser/api/lib/atom_api_web_contents.cc
as say
bool WebContents::GetOkOk() {
return true;
}
And define the same in it'h header file
electron/atom/browser/api/lib/atom_api_web_contents.h
as
bool GetOkOk();
Lastly you need to export the function through the webContents method located in
electron/atom/renderer/lib/web-view/web-view.js
as
/* Public-facing API methods. - modified by Akshay Thakare */
methods = ['getOk','getURL', ... ];
And you are good to go.
Finally after you compile your electron app,
in the main.js file add,
console.log(mainWindow.webContents.getOk());
and your done.
As JS is prototype oriented, you could simply extend the BrowserWindow API
var BrowserWindow = require('electron').BrowserWindow; // main process
var BrowserWindow = require('electron').remote.BrowserWindow; // renderer process
BrowserWindow.foo = function() {
console.log('foo');
}
Not sure if you're looking for someting more specific, but I'm not sure you can extend it with heavy impacts on the system, could you explain exactly what you are trying to do ?

MVVMCross CrossUI.Droid Hello World

I am Trying to use MVVMCross CrossUI Droid on its own for a quick test from here
In VS2013 I have created a new Android Application, added CrossUI and changed the target framework on CrossUI.Core (ticked all + 4.5+) to compile CrossUI.Core and CrossUI.Dialog.
The link for layouts in the ReadMe paragraph gives a 404 error.
"... and add these layouts to your Resources/Layout folder: Android.Dialog Layouts Expect an easier way to manage this after Mono for Android 4.4 is released."
I assume they will still be needed in layout as I get a missing layout error on run.
I have also "tried" to add some dialog layouts from old project that can be found here
using code (I am trying to piece this together but could be way off hence this help request) -
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
DroidResources.Initialize(typeof(Resource.Layout));
var Root = new RootElement()
{
new Section("Test Section")
{
new StringElement("Test:"),
}
};
var da = new DialogAdapter(this, Root);
var lv = new ListView(this) { Adapter = da };
SetContentView(lv);
}
still get -
02-28 10:56:32.639 E/Android.Dialog( 2382): LoadLayout failed: Could not find resource field dialog_multiline_labelfieldbelow
02-28 10:56:32.639 E/Android.Dialog( 2382): LoadStringElementLayout: Failed to load resource: dialog_multiline_labelfieldbelow
Could someone show / point me to a / some working sample(s) for getting CrossUI.Droid Dialogs rendering on screen?
Thanks for your help
I think you no longer need to include the resources manually when using MvvmCross.
The easiest starting point for this are probably:
The MvvmCross DialogExamples app
The N+1 video - see N=23 in this blog - including blog and code links

Control view Stack in MvvmCross

How I handle the view stack?
I use MvvmCross and I don't look up the way to do this.
I have a project, I add a custom SplashScreen that I want remove of view Stack.
Thanks in advance.
I don't think there is a direct method to do that for you.
I believe the best way to do this is to create your own custom view presenter and then from within that depending on which platform you are on you can customise your stack of views. For example in iOS you can manipulate MasterNavigationController in a way similar to the answer here.
To find out how to do the custom presenter you can watch N=24 and N=25 in MvvmCross N+1 videos
A general template for an iOS custom view presenter looks like this:
public class CustomPresenter : MvxTouchViewPresenter
{
public CustomPresenter(UIApplicationDelegate applicationDelegate, UIWindow window)
: base(applicationDelegate, window)
{
}
public override void Close(IMvxViewModel toClose)
{
//your custom code on what to happen when a view model is closing
base.Close(toClose);
}
public override void Show(Cirrious.MvvmCross.Touch.Views.IMvxTouchView view)
{
//your custom code on what to happen when a view model needs to be shown
base.Show(view);
}
}

Wordpress―run JS after Widget was created in Admin panel

I am developing a Wordpress Theme that includes a custom Widget, everything works out fine but there is one thing I do not know how to implement correctly:
I would like to run some Javascript after the Widget Instance was created in the admin panel, that means in the very moment after the widget was dropped in a sidebar, not after saving.
I have no Problems with running JS after the page was loaded or the Widget was saved, I want to run Javascript after the User just dropped a new Instance into the side bar, what actually can happen more than once without page reload.
Greetings philipp
Another way of doing this I just figured out --
I'm going to show a more complex example involving dependencies, though realise the bit in Custom_Widget::form() is the real answer to the question:
function add_js_deps() {
if (is_admin()) {
wp_enqueue_script('jquery-ui-accordion');
}
}
add_action( 'init', 'add_js_deps' ); // "init" because wp_enqueue_scripts is too late.
// Then in the widget....
class Custom_Widget extends WP_Widget {
public function form($instance) {
/** Collapsing accordion-y form HTML here **/
wp_enqueue_script('custom-js', plugins_url('js/my.js', __FILE__), array('jquery-ui-accordion'), '1.0.0', true);
}
}
I'd argue this is the better route as it has dependency management and you won't have a bunch of JavaScript mid-way into your DOM. Using wp_enqueue_script is generally always the more WordPressian way of doing things regardless.
Place a script tag in the widget form function.
function form($instance)
{
?><script type="text/javascript">console.log("firing javascript");</script>
<?php
//form details...
}
I eventually went a different way with this. Loaded our plugin admin script on the page using wp_enque_script and then just used jquery selectors and an event handler to target the right widget.
$('div.widgets-sortables')
.on('sortstop', function (event, ui) {
// only if this widget has the proper identifier...do something
if (ui.item.find('.my_widget').length == 0)
return;
run some function...
Still not my favourite technique...but it is cleaner then coding it in the widget. Does require a variable to track created widgets and using the "this" variable is useful

Gtk# + MonoDevelop: How to pop-up a custom widget on button click

I am new to Gtk# and Monodevelop. So please forgive the basic-ness of this question. But I am trying to do something really simple - and I can't seem to do it. Not sure if it matters, but I am developing on Linux
I have a MainWindow which has a button. When I click on this button, I want a custom widget to pop-up
I created a custom widget as a separate project, compile it as a .dll and refer it in the main project
In the main project, I have defined a call-back for button click - loadCustomWidget()
However, the code below does not show the custom-widget on screen
public partial class CustomWidget : Gtk.Bin ; // in the other project
protected void loadCustomWidget() {
Console.WriteLine(" show custom widget ") ;
wg = new CustomWidget() ;
wg.Show() ;
}
The WriteLine() is printed. So I know the call-back is being called. But why isn't the widget showing on screen?
You need to put the widget into a container, for example add it to your main window.