Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
lawrence_shaun_introducing_net_maui_build_and_deploy_crosspl.pdf
Скачиваний:
46
Добавлен:
26.06.2023
Размер:
5.15 Mб
Скачать

Chapter 5 User Interface Essentials

FontAttributes="Bold" />

<Entry Keyboard="Numeric" /> </VerticalStackLayout>

</VerticalStackLayout>

<Button

Text="Save" HorizontalOptions="End" />

</VerticalStackLayout>

Yes, I know! I spoke about keeping the visual tree simple and here you are nesting quite a few layouts. I find there is typically some level of pragmatism that needs to be applied. This page is still relatively simple in terms of what is being rendered on screen so I will argue that it is fine. If you were to repeat this layout multiple times, you would need to be a little more strict and find the best way to lay it all out. Quite often you will find that there can be a balancing act between defining something to give the best performance vs. making it easier to maintain as a developer.

So you have now built your UI but you will notice that it doesn’t do anything other than let the user type in the entry fields. You need to bind the view up to your view model.

This is not strictly part of layouts but it is worth noting how you apply the Keyboard property to your Entry controls. This allows you to inform the operating system what soft keyboard to display and therefore limit the type of data the user can enter. Note that this only applies to mobile applications.

Data Binding

UI-based applications, as their name suggests, involve presenting an interface to the users. This UI is rarely ever just a static view and therefore needs to be updated, drive updates into the application, or

135