How to click button and open another View?

Hi. Noob here. My experience 100% on iOS (XCode) objC only.
I am surprised there aren't any easy tutorial for Xamarin MVVMCross that goes
beyond helloworld but not too complicated.

I am following Xamarin MVVMCross tutorial in youtube and on the iOS app portion.
I managed to create the xib using XCode and reopening it on xamarin studio, naming the
objects. But I don't have any idea how to assign the button to an eventhandler (onclick),
and upon clicking it opens another Page?

Any guide or sample code is much appreciated.

Best Answer

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    First question: If you're new to it what made you decide to add MVVMCross? What was lacking in the built-in MVVM support that made you feel you needed a 3rd party package?

    I don't have any idea how to assign the button to an eventhandler (onclick),

    Don't. Please don't use that old .Click crap. That's carry over to ease the transition from WinForms to WPF. But it really shouldn't be used in modern XAML/WPF/Xamarin. Assign a Command in accordance with good, modern XAML/MVVM principals.

    Honestly - if you're this new to XAML/MVVM concepts and are still working on the basics I would suggest taking out MVVMCross. You just don't need to complicate your life by trying to add stuff you don't have a need for.

    Getting started Xamarin site page

    Creating mobile apps in Xamarin - Free ebook download - the de facto textbook for Xamarin.

    You should probably give serious consideration to Xamarin University. Its a flat rate for taking all of their courses. From intro to C# to advanced memory management in Android, to network administration. Its not free, but it is a really good value for the volume of education you get out of it. You can try to source out 30 different free YouTube videos and websites or you can take a cohesive guided course that will teach you more, better and faster. Its your education toward your career aspirations: You get what you pay for.

  • GeneCodeGeneCode USMember

    Hm... quite a different response from xamarin forums compared to XCode forums.

    I'll keep that in mind. Have a nice day.

  • vkt_rbvkt_rb USMember ✭✭✭
    edited April 2017

    Hi @GenCode, well it's a very huge different between xamarin.forms /xamarin.iOS and Swift or Objective C to develop and app for iOS devices, but answering to the Tittle of your post ... In xamarin.iOS project you can use a storyboard very very similar to XCode, if you were working with objective C or Swift you will see that it's very similar to develop an UI in iOS, but of course the code behind will be in c#, but for example for a UIButton "eventhandler (onclick)" you can use the Touched Up Inside event of the UIButton and in there you can open the another UIViewController as in native iOS develop, here's and example of the code in the event:

        partial void btnIconoPerfil_TouchedIn(UIButton sender)
                    {
                        try
                        {
                            var StoryBoard = UIStoryboard.FromName("Main", null);
                            StoryBoard.InstantiateViewController("EdicionPerfilController");
    
                            EdicionPerfilController RegistroV = this.Storyboard.InstantiateViewController("EdicionPerfilController") as EdicionPerfilController;
    
    
                            if (RegistroV != null)
                            {
                                this.NavigationController.PushViewController(RegistroV, true);
    
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
    
                        }
                    }
    

    Attached is a screenshot of the xamarin storyboard, and the UIButton owner of the event before

  • vkt_rbvkt_rb USMember ✭✭✭

    As you can see it's very similar to develop in native iOS (Swift or Objective), to be honest I learned first xamarin.iOS and xamarin.Forms before to Swift and as personal experience I could say that it's not very difficult to accustomed developing in Xamarin if you have the knowledge from native iOS and about architecture's project I use MVVM to develop the solutions

  • vkt_rbvkt_rb USMember ✭✭✭
    Well.... Yes jeje sorry pretty similar the nicknames... Thanks @GenCode
  • GenCodeGenCode USMember
    edited April 2017

    np ;-)

Sign In or Register to comment.