Guidance

I am new to xamarin forms and I am trying to make a contact app. I want to have a list of departments and when a department is selected, it navigates to a list of employees within that department. From there when a specific employee is selected it navigates to a details page about that employee. What would be the best day to do this and the best way to store and retrieve the data, etc. I have a working app with just a list of employees that navigates to details and it is pulling from a json url but I can't figure out how to implement the department part of it using this method. I have attached a sketch of what I am wanting to do so it can be visualized. Thank you!

Posts

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Start with working the free textbook from cover to cover.
    https://blogs.msdn.microsoft.com/microsoft_press/2016/03/31/free-ebook-creating-mobile-apps-with-xamarin-forms/

    Getting started in Xamarin
    https://docs.microsoft.com/en-us/xamarin/cross-platform/get-started/

    XAML Basics
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/xaml-basics/

    Data binding basics
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/xaml-basics/data-binding-basics

    Feel free to hit up on-line tutorials sites. There are plenty. Here's mine:

    When you say

    Its my first time using Xamarin.

    If you really mean

    Its my first time doing any coding at all

    Then stop and don't get into Xamarin at all yet. First you need to learn C# which is the language all your logic and actual 'code' will be written in. Xamarin is an eco-system that your code operates within so that the same code can run on iOS, Android, UWP, MacOS and Tizen without having to create separate solutions for each platform. But if you can't first write code - any code - then it does you no good to try to figure out cross-platform deployment.

    Once you are at least somewhat comfortable in C# then look into MVVM design. It is the foundation concept that any app in the last 15 years should be based on, whether that's a Windows WPF program or a Xamarin cross-platform app. If you have no experience with MVVM design... no experience with databinding code to UI... etc. etc. then you need to first get a handle on that.

    Then realize you can't just jump into make your "goal application" as your first project. Your first application can't be an entire inventory and ordering system for your uncle's restaurant, or scheduling app for your sisters delivery service.

    You have to start with building a bird house... then a dog house... then an outhouse... shed... garage... Before you try to build a 3 story apartment building. You have to apply that same "start small and learn" approach to software development. You start by building small apps alike alarm clocks and mortgage calculators, and work up from there learning UI development, OOP and other basics along the way. Then you take those skills to your next bigger project. In other words you have to learn how to be a coder before you can be a software architect.

    When you're ready to start designing an intermediately complex app just tackle one issue at a time in a "Sandbox" or R&D app.
    Start with the first basic need: People
    That's not Xamarin in any way. Just define a Person class. And then inherit from that for a User class. And you'll want a Rights class to be the permissions for that User object.

    Then probably some type of grouping... whether its groups of people or groups of things. Learn how to work with collections of objects.

    But learn each of your bullet points one at a time in a little R&D app before you try to take on putting them all together. You need to understand them as a single thing before you can architect how they will interact.

    In the end... 90% of of the typical app has nothing to do with Xamarin. Its all basic-to-intermediate C#, application architecture and design that would be the same in Xamarin, WinForms, WPF, Android, ...

    inding and DataTriggers are foundation concepts within XAML/MVVM development. You really can't make a program without an understanding of these. I strongly encourage you to stop coding on your project until you take the time to study these. A proper understanding of these concepts will dramatically change the way your approach your solution and alter the direction of how you architect the app. So there's little point gerry-rigging something now that you'll rip out later once you understand how it should have been done. In other words, 40 hours of learning now will save you hundreds of wasted hours later - not to mention all the money you'll save in aspirin if you aren't suffering all the headaches from trying to build your app without a good foundation of understanding.

    Xamarin University YouTube channel
    https://www.youtube.com/channel/UCykEmj8H8O0aE6QB1965XCg

    Microsoft Learn, Xamarin search results
    https://docs.microsoft.com/en-us/search/index?search=Xamarin

    Red Pill Xamarin tutorial series
    http://redpillxamarin.com/2018/03/12/2018-101-vs2017-new-solution/

  • grayson_alexandergrayson_alexander Member ✭✭
    @ClintStLaurent
    Thank you for your response! I am not new to programming, just new to xamarin forms and C#. I went through some pluralsight courses and built some samples apps before starting this project. I was able to get pretty far on the project I'm doing now but I'm stuck implementing the departments. I will work on gaining a better understanding overall and hopefully can get past this snag. I'm not sure why I'm having so much trouble with it.
  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭
    edited June 17

    @grayson_alexander said:
    @ClintStLaurent
    Thank you for your response! I am not new to programming, just new to xamarin forms and C#.

    Okay. Sounds promising. So if you're new to C# then you're new to .NET framework... MVVM pattern for your app... Does that sound about right? What programming did you do before this; just to get an idea about your experience?

    I want to have a list of departments and when a department is selected, it navigates to a list of employees within that department. From there when a specific employee is selected it navigates to a details page about that employee.

    Well... First off C# is Object Oriented Programming. Do you have experience doing OOP? Are you familiar with the idea of needing to make a Department class... an Employee class... a Person class and so on?

    I presume all this data is in a database someplace. I'm going to guess its something like this:

    DepartmentTable
    ID, internal code, friendlyname

    EmployeeTable
    ID, all the fields of an employee

    EmployeeAssignmentTable
    ID, EmployeeID, Department ID

    So you do a fetch for all the departments - Dump them into an ObservableCollection<Department> and use it as the .Source of a Picker.
    When the user selects one you have the ID of the Department in a property such as SelectedDeptID

    Fetch all the Records from the EmployeeAssignmentTable where (that's a hint) the DepartmentID like SelectedDeptID (another hint). Dump them into an ObservableCollection<Employee> and make that the .Source of a Picker.

    When the user selects someone you have their ID. Now fetch their data from the EmployeeTable and set it as the BindingContext of your EmployeePage.

  • grayson_alexandergrayson_alexander Member ✭✭

    @ClintStLaurent Yes that's correct! I am going into my fourth year of college studying computer science with an emphasis in mobile computing. I've had experience with quite a few languages but only about as much as a semester can teach you for most of them. I've written in Python, quite a bit in Java (both console and Android apps), Swift for iOS and WatchOS, a little but of C, and a little bit of ARM Assembly. I will admit I am not the best programmer. At least not in my own opinion. I have the most experience in Java and Swift I would say. I have a summer internship where I am writing this POC app using Xamarin Form so I am trying to learn it enough to be proficient or at least enough to be able to create this app. I might be trying to do too much too fast and may need to take a step back and make sure I have a strong understanding of everything before continuing on my app.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    The key is going to be grasping OOP concepts and getting up on C#.
    Grab a couple "Learn C# in 60 days" books off amazon.

    Learning C# is going to be a lot more important than trying to learn Xamarin without it.
    You don't show up to the NASCAR training camp, then ask "Which one is the brake?"
    You have to understand the foundation concepts. If you don't have C#/.NET/OOP you don't have the foundation Xamarin is built on. The internship will help teach you the Xamarin - IF they have something to build upon.

Sign In or Register to comment.