Exploring .NET MAUI: Data Entry Controls and Data Binding
CODE Magazine|November - December 2024
In the first parts of this ongoing series on exploring .NET MAUI (https://codemag.​com/Article/2408041/Exploring-.NET-MAUIGetting-Started and https://codemag.​com/Article/2409041/Exploring-.NET-MAUI-Styles-Navigation-and-Reusable-UI), you created your first .NET MAUI application and ran that application on both a Windows computer and an Android emulator.
Paul D. Sheriff
Exploring .NET MAUI: Data Entry Controls and Data Binding

You created data-entry pages, partial pages to reuse on those pages, and you navigated among those pages. In this article, you’ll continue to use more data entry controls and learn to perform data binding between controls. You’re going to create a class with properties that you can bind to controls on a page as well. When you change the values of properties in a class, you need to raise a PropertyChanged event so the UI can update those controls that are bound to the properties. You’re going to create a base class that helps you raise that event any time the property values change.

Use a Switch Control for Yes/No Input

Simple entry controls allow a user to enter any data they want. For some input you need a simple yes or no answer from the user. For example, if you have a Boolean property such as IsEmployed on a business object, use a Switch control to represent the two states for this property. On a Windows computer, the Switch control appears as a toggle coupled with a label next to it with the words On and Off, as shown in Figure 1.

Open the Views\UserDetailView.xaml file and add an Auto to the RowDefinitions attribute of the Grid control. Locate the last <HorizontalStackLayout> starting tag at the bottom of the Grid and change the Grid.Row property to "7" instead of "6". Just before the <HorizontalStackLayout> starting tag you just modified, add the following XAML that creates the Switch control:

Try It Out

Run the application and click on Users > Navigate to Detail to see the switch control. Click on the Switch control a couple of times to see the labels change.

Override the Switch Labels

この記事は CODE Magazine の November - December 2024 版に掲載されています。

7 日間の Magzter GOLD 無料トライアルを開始して、何千もの厳選されたプレミアム ストーリー、9,000 以上の雑誌や新聞にアクセスしてください。

この記事は CODE Magazine の November - December 2024 版に掲載されています。

7 日間の Magzter GOLD 無料トライアルを開始して、何千もの厳選されたプレミアム ストーリー、9,000 以上の雑誌や新聞にアクセスしてください。

CODE MAGAZINEのその他の記事すべて表示
Threads, Asynchrony, Parallelism, and Concurrency in C#
CODE Magazine

Threads, Asynchrony, Parallelism, and Concurrency in C#

The concepts of process, thread, and task are fundamental to understanding the working of an operating system. You should have a good understanding of threads and how they work to learn asynchrony, parallelism, and concurrency. This article discusses the concepts related to these concepts in detail with relevant code examples wherever appropriate.

time-read
5 分  |
November - December 2024
Career Development and Staffing Reinvented
CODE Magazine

Career Development and Staffing Reinvented

You think great talent and cool positions only exist in Silicon Valley? Think again!

time-read
4 分  |
November - December 2024
Can an LLM Make a Video Game?
CODE Magazine

Can an LLM Make a Video Game?

In the Summer of 1980, I played Asteroids at a gas station in rural West Texas. I stood on a stool to reach the controls and see the screen. Ever since then, I’ve wanted to make a video game. I’ve also wanted to have the time, skills, and resources to make a video game.

time-read
3 分  |
November - December 2024
First Rule of ARIA: Don't Use ARIA
CODE Magazine

First Rule of ARIA: Don't Use ARIA

As you expand your accessibility knowledge, you've probably heard the term ARIA a few times, maybe with an explanation, maybe not. Let's start there: ARIA (https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) is a standard from the World Wide Web Consortium (W3C) (https://www.w3.org/) via the Web AccessibilityInitiative (WAI) (https://www.w3.org/WAI/).

time-read
10+ 分  |
November - December 2024
Exploring .NET MAUI: Data Entry Controls and Data Binding
CODE Magazine

Exploring .NET MAUI: Data Entry Controls and Data Binding

In the first parts of this ongoing series on exploring .NET MAUI (https://codemag.​com/Article/2408041/Exploring-.NET-MAUIGetting-Started and https://codemag.​com/Article/2409041/Exploring-.NET-MAUI-Styles-Navigation-and-Reusable-UI), you created your first .NET MAUI application and ran that application on both a Windows computer and an Android emulator.

time-read
4 分  |
November - December 2024
CODE Magazine Presents: The State of AI Mini Conference Tour
CODE Magazine

CODE Magazine Presents: The State of AI Mini Conference Tour

CODE has recently started a new series of inperson events focusing on the topic of artificial intelligence and its practical uses in business scenarios.

time-read
2 分  |
November - December 2024
AI with No Internet Connection
CODE Magazine

AI with No Internet Connection

AI, or artificial intelligence; are you bored of hearing about of it yet? Between the stock market and CEO keynotes, we can’t seem to get away from it. It promises to revolutionize everything around us.

time-read
8 分  |
November - December 2024
CODE: 5 Years Ago
CODE Magazine

CODE: 5 Years Ago

And just like that, we've arrived at the last installment of our \"30 Years of CODE\" celebratory column. Wow. Time flies! Seems like \"just the other day\" we had our 30-year anniversary celebration in Orlando, yet that was in December of 2023. But it's even wilder to think back five or six years. \"Just before the pandemic,\" really. How much has changed in those few short years!

time-read
10 分  |
November - December 2024
Career Development and Staffing reinvented
CODE Magazine

Career Development and Staffing reinvented

You think great talent and cool positions only exist in Silicon Valley? Think again!

time-read
4 分  |
September - October 2024
Container Orchestration Using Kubernetes
CODE Magazine

Container Orchestration Using Kubernetes

In my previous article on Docker (\"Introduction to Containerization Using Docker,\" Mar/Apr 2021 issue), I explained what containerization is and how Docker simplifies application deployment.

time-read
2 分  |
September - October 2024