Control view Stack in MvvmCross - 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);
}
}

Related

Tabbed navigation using mvvmcross and xamarin forms

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> ();
}
}

How to override the Render method?

I'm looking at a control that must output raw HTML and provide rich design-time support.
How to create a custom server control, extend the WebControl class and override the Render method?
Can you provide an example?
regards,
Blanco
This will create a control that extends web control and overrides the Render method (though doesn't actually do anything with it.
public class TestControl : System.Web.UI.WebControls.WebControl
{
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
base.Render(writer);
}
}
As you can see this is a fairly trivial answer but complete so I suspect that you didn't actually ask the question that you intended to.

WindowsPhone CreateBindingSet testing

I am now moving from my code behind xaml dp binding to using CreateBindingSet, as I believe it will be easier to maintain on long run. Previously to confirm that I haven't missed any binding, I had a Windows Phone Test project with a generic test routine - that would parse a view for all the controls, and confirm that each has a correct binding. I did this using
element.GetBindingExpression(dependencyProperty) // from System.Windows
and that's worked beautifully - validating all my views.
But now as I am changing over, all these tests are failing. Has anyone any suggestions on how I can test same thing with when the binding is applied using CreateBindingSet and .Apply.
Thanks in advance.
Rana
Reasoning behind the Madness
Being a lazy sod, I dream of a day where my View would be shared across all platforms; until then, the following would do (I have most in place and working)
BoilerPlate class that would be shared between all platforms:
#if __IOS
... needed namespaces
#else ....
public partial class FirstView
{
private new FirstViewModel ViewModel
{
get { return (FirstViewModel)base.ViewModel; }
}
private void CommonBinding()
{
var set = this.CreateBindingSet<FirstView, FirstViewModel>();
// do common bindings
set.Bind(PageText).For(c => c.Text).To(vm => vm.PageText).OneTime();
set.Apply();
}
}
Then View in Touch would be:
public partial class FirstView : MvxViewController
{
public override void LoadView()
{
// create
}
public override ViewDidLoad()
{
CommonBinding();
}
}
In theory, Views in other platform would be almost similar; just different inheritance (MvxActivity with OnCreate, and OnViewModelSet)/(MvxPhonePage with xaml/alternative, and Loaded Event for binding).
Finally, a common testing way to ensure that all the items has binding set somehow. In my mind, until autoview is supported in wp8, it's just the way to have as much shared code as possible.
I have just started on droid, and trying to make the layout compatible with xibFree, which I have already used in my touch project. If this works, I can then have shared layout between droid and touch (perhaps I should be looking at autoView anyway)
I'm personally not sure what value these tests add that much value to your application - these feel like they are operating at a level of "duplicating code" rather than actually testing any functionality.
However, this is very much down to personal opinion, and if you do want this level of testing, then I think you could do this by:
Inherit a class from https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross.BindingEx.WindowsPhone/WindowsBinding/MvxWindowsBindingCreator.cs
Override ApplyBinding so that you can capture at test time the calls made for each element
Register this class with ioc as the IMvxBindingCreator in your test harness
Use the captured lists of binding requests in your tests

Scala: Equivalent of WPF Canvas and Polygon

I'm developing a Hex based Game. Having wrestled with the limitations of the C# type system, on discovering Scala I knew I had to rewrite the application in Scala. I need a basic GUI to be able to develop the main functionality. I've been using a WPF Canvas with Polygon class. I also use Wpf Border class and Line class on the Canvas. I don't need most of the functionality of Wpf. I don't use Xaml. i just need to map the graphical objects to the desired coordinates, receive left and right mouse click events from them and put up tool tips and display context menus. I don't even need the Wpf context menu property as as I prefer to the context menus to be dynamic. I handle scrolling and zoom through my own code.
The best that I've found to make Polygons is the awt GeneralPath class. Although this is supposedly depreciated. I've started with Scala Swing, but the MainFrame class will not allow me to use the awt canvas class as content. Any help / recommendations appreciated
just override paint of some Component:
public class MyCanvasPanel extends JPanel{
...
#Override
public void paint(Graphics g){/* do your java2d stuff here*/}
}

can't access user control public properties

I am using VS2008 with both VB.NET and C#
I have created a simple custom user control and have added some public functions to it
my problem is that if I don't drag and drop the user control from the toolbox onto a winform but instead I try to create one dynamically via code - I am not able to access the public functions and properties
I can't understand why there would be a difference but htere seems to be.
would appreciate any help on the matter
thanks
You are defining your variable as type UserControl. As such, intellisense is only going to show you the members of the UserControl class, even if it is in fact of type myCustomControl.
Change your initial declaration to myCustomControl myUC; and you should be good to go.
You neeed to type cast to the usercontrol type
then it works
For Ex :
public partial class uctls_contact_uctlCompanyViewContacts : System.Web.UI.UserControl
{
public bool ReadOnlyMode
{
get;
set;
}
}
UserControl uctlCompanyViewContacts = (UserControl)Page.LoadControl("uctlCompanyViewContacts.ascx");
uctlCompanyViewContacts.ID = "uctlCompanyViewContacts";
panelCompanyViewContacts.Controls.Add(uctlCompanyViewContacts);
((uctls_contact_uctlCompanyViewContacts)uctlCompanyViewContacts).ReadOnlyMode = true;
Are you using the LoadControl method to load the control?
ie.
MyControl ctrl = (MyControl)LoadControl("~/MyControl.ascx");