I am new to XAML / Xamarin.forms and come from a web-development background.
I am looking to make a box containing with text and images (like that can be done using a <div>
in HTML). Please explain how to approach this with XAML & Xamarin.forms.
Also, if anybody knows a resource that lists the available tags in XAML (like w3schools for HTML), please pass that on to me.
Thanks in advance :)
Xamarin.Forms XAML Basics. XAML—the eXtensible Application Markup Language—allows developers to define user interfaces in Xamarin.Forms applications using markup rather than code. XAML is never required in a Xamarin.Forms program, but it is often more succinct and more visually coherent than equivalent code, and potentially toolable.
The article explains how to use Xamarin.Forms XAML markup extensions to extend the power and flexibility of XAML by allowing element attributes to be set from sources other than literal text strings. The TranslateExtension allows users to handle multi-language support in XAML at runtime.
In simple words, Compiled Bindings just tells your app to compile the XAML stuff before you run the app. Catches spelling errors and other issues with data binding at compile-time and build time itself. Let's take the XAML code from my article BindableLayout as an example for understanding what is Compiled Bindings in Xamarin.Forms.
Behaviors are written in code and added to controls in XAML or code. Behaviors are the best way to validate the user inputs such as email, phone number, etc. Start by creating a new Xamarin.Forms project.
Why not check out the Xamarin documentation on this? It is quite extensive and should help you with the basics!
There isn't a exact equivalent of a div. It depends on what you want to do. It all starts with a Page
. You see the types of pages below.
That will be the base of your app. Within this Page you can have one VisualElement
, which kind of forces you to use a Layout
.
Here you see all the layouts that are available to you;
The good news is you can nest Layouts
!
In a Layout you can specify your controls (of type View
).
To get back to your question; the behaviour is different than a div. If you take a StackLayout
for example your nested controls will be stacked on top of each other and you don't have to worry about spacing, margin, etc. Another option is to go for a Grid
which gives you a bit of flexibility.
So it's not just a container it also means something in terms of how it is placed on the screen.
I also explain some basics on my blog here and here but there are a lot of resources out there which can help you get started.
Just use a Frame:
<StackLayout>
<Frame x:Name="MyPanelABC">
<Label Text="My Stuff" />
</Frame>
</StackLayout>
private void setupPanelABC(bool isVisiblePanelABC){
MyPanelABC.IsVisible = isVisiblePanelABC;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With