Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

How to create my own View class correctly

$
0
0

Dear XAMARIN experts,

I would like to ask you how to create the View classes correctly in XAMARIN Forms. I have got used to a specific structure in the Windows Forms.
Problem: Create my own Label class which inherits from Xamarin.Forms.Label and specify its properties.

Attempt:
1.) I created View Class in a project (called ColourLabel)

2.) I changed namespace from MyProject.Views to MyProject

3.) I specified the properties in constructor:
this.BackgroundColor = Color.Gray;
this.MinimumWidthRequest = 100;
this.HorizontalTextAlignment = TextAlignment.Center;
this.FontSize = 16;

I am not sure whether this is a proper way of structuring code in Xamarin. Moreover, I doubt that the XAML file created would have any meaning now (I changed namespace).

Thank you for your help.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>