7 Replies - 650 Views - Last Post: 24 July 2017 - 04:56 PM

#1 Dialupp  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Xamarin C# Don't understand this code

Posted 13 July 2017 - 01:12 AM

I don't get the part on rowDefinitions how for the first row we put a "*" icon. I think what it is saying is that the first row will be twice the size of the second and third row?

    <Grid Padding="20">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="40" />
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>
        <StackLayout Grid.Row="0" VerticalOptions="Center">
            <Label Text="Welcome to Xamarin" FontSize="30" TextColor="White" HorizontalOptions="Center" />
            <Label Text="Cross-platform apps made easy" FontSize="18" TextColor="White" HorizontalOptions="Center" />
        </StackLayout>
        <Button Grid.Row="1" Text="Login" BackgroundColor="#1dabf0" TextColor="White"  />
        <Button Grid.Row="2" Text="Register" BackgroundColor="#1dabf0" TextColor="White" />
    </Grid>



Is This A Good Question/Topic? 0
  • +

Replies To: Xamarin C# Don't understand this code

#2 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6508
  • View blog
  • Posts: 14,375
  • Joined: 02-June 10

Re: Xamarin C# Don't understand this code

Posted 13 July 2017 - 03:11 AM

This is not C#, it is XAML. XAML is not 'code', it is 'markup', because it is not executable - it only describes UI and describes bindings. During compile-time Visual Studio will generate code from the markup.

Rather than bang on the keyboard guessing and trying to reverse-engineer an understanding of an entire language you should work through some of the thousands of tutorials already out there. The simple fact is, we can't provide an entire XAML course in one thread, any more than we could provide a C# course in a thread.
https://www.google.c...=utf-8&oe=utf-8

Xamarin XAML is only slightly different than WPF XAML. StackLayout instead of StackPanel, that sort of thing just to keep the namespaces from confusing controls. But 90% of it is all the same - like defining Grids, Rows and so on. So if you find a tutorial teaching WPF XAML most of it will apply to Xamarin XAML as well.

Since it is clearly all new to you, I would encourage you to sign up for Xamarin University and take guided, structured courses on-line. You can also work through Xamarin's on-line walk-thrus plus the mountains of free course they have on their YouTube channel. Generally I discourage YouTube for learning because is 90% schmucks. But if you follow the actual Xamarin University courses they follow a consistent roadmap and are professional grade. At the very least, start with Charles Petzold's free book. Its the de-facto text book on Xamarin and its free.


> I think what it is saying is that the first row will be twice the size of the second and third row?
No. I can't even imagine where you gleaned "twice" from "*".

Meaningful google searches also do wonders. For example... When I search "XAML tutorial grid row", the first result is this one:
http://www.wpf-tutor...ws-and-columns/

How to do a search with good terms to get meaningful results:
http://www.dreaminco...f-the-internet/

This post has been edited by tlhIn`toq: 13 July 2017 - 03:13 AM

Was This Post Helpful? 0
  • +
  • -

#3 Dialupp  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Re: Xamarin C# Don't understand this code

Posted 13 July 2017 - 03:21 AM

Sorry accidentally wrote it as c# not xaml. I am having trouble visualizing the result.

I was following this udemy course. Jumping through resources constantly is really pissing me off.
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1533
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: Xamarin C# Don't understand this code

Posted 19 July 2017 - 06:14 AM

This...

View PosttlhIn`toq, on 13 July 2017 - 06:11 AM, said:

At the very least, start with Charles Petzold's free book. Its the de-facto text book on Xamarin and its free.


If you are doing Xamarin.Forms, then you should have this book. You have no excuse for not reading it. It's free!!

For a quick answer, "*" means take up the available space. So you will have three rows, bottom two will be 40 points high, and the top row will take up everything else.
Was This Post Helpful? 1
  • +
  • -

#5 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6508
  • View blog
  • Posts: 14,375
  • Joined: 02-June 10

Re: Xamarin C# Don't understand this code

Posted 19 July 2017 - 03:07 PM

View Posteclipsed4utoo, on 19 July 2017 - 07:14 AM, said:

For a quick answer, "*" means take up the available space. So you will have three rows, bottom two will be 40 points high, and the top row will take up everything else.


No, it does not. It means "take up one unit out of the total number of units that object will occupy".
So if you have
Row Height = "*"
Row Height = "*"
Row Height = "*"
Row Height = "3*"
Row Height = "4*"

There is a total of 10* to be divided across all the rows. (1 + 1 + 1 + 3 + 4) = 10
Each row will get is RELATIVE allocation of space based on divvying up all the space.
Do not confuse this with percentage. It is no 3% or 30%. It is 3 out HoweverManyTotal. If you add 15 more rows of 1* each it become 3/25 for example.

If a row ends up filling any unavailable space it is not because of the * value - It is actually a side affect of the nature of the grid and other settings such as VerticalOptions = "FillAndExpand" - If you tell the grid to fill the available a space and you've hard set a row to 40DiP tall then something has to expand someplace in an effort to fulfill your order to FillAndExpand - and the row with the variable height it considered the better candidate than the one hard set to a fixed size.
Was This Post Helpful? 0
  • +
  • -

#6 Dialupp  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Re: Xamarin C# Don't understand this code

Posted 19 July 2017 - 03:58 PM

That makes sense thanks. A question, I really suck at solving exercises in fact I can't do them without looking at the solution, sometimes its because I can't remember the previous information or the instructions may confuse me. What should I do in this case?
Was This Post Helpful? 0
  • +
  • -

#7 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6508
  • View blog
  • Posts: 14,375
  • Joined: 02-June 10

Re: Xamarin C# Don't understand this code

Posted 20 July 2017 - 05:21 PM

View PostDialupp, on 19 July 2017 - 04:58 PM, said:

That makes sense thanks. A question, I really suck at solving exercises in fact I can't do them without looking at the solution, sometimes its because I can't remember the previous information or the instructions may confuse me. What should I do in this case?


Frankly.... bluntly... honestly... Find a job that doesn't require problem solving skills. Coding is not it. A person can learn information. But you can't learn your way out of genetics. A fat guy is not going to be a track star... A midget isn't going to play in the NBA... A Paclad is not going to be a scientist and a Klingon is not going to be the ship's councilor... And someone who's brain isn't wired for problem solving is not going to be a good detective, or software engineer. Its nothing mean or hurtful, its just genetics.

Coding is nothing but problem solving skills, seeing the bigger picture... seeing the bigger puzzle... not only finding the solution but often times architecting the puzzle and then the tools to find the solution and then the solution.
Was This Post Helpful? 1
  • +
  • -

#8 Dialupp  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Re: Xamarin C# Don't understand this code

Posted 24 July 2017 - 04:56 PM

Funny thing is I quit programming a few weeks ago then gave it another shot, but yeah I'm done with it, thanks for the help on the forum over the last few months though.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1