Minh  Nguyet

Minh Nguyet

1659357360

Khám Phá đa Windows Trong .NET MAUI

Đa cửa sổ là một tính năng hay trong .NET MAUI và chúng tôi có thể cung cấp thêm TLC cho phiên bản máy tính để bàn của chúng.

.NET MAUI là một công cụ tuyệt vời cho phép bạn tạo các ứng dụng có cùng cơ sở mã chung cho cả máy tính để bàn và thiết bị di động và có thể được phát triển cho Android, iOS, macOS và Windows.

Một số tính năng hữu ích hơn trên phiên bản máy tính để bàn của một ứng dụng và do đó sẽ cần chú ý thêm. Một trong những chức năng như vậy là nhiều cửa sổ. Máy tính để bàn và máy tính bảng có thể cho phép nhiều cửa sổ và chế độ xem khi bạn mở ứng dụng. Trên các thiết bị này, chức năng này nặng hơn và cần thiết hơn, tuy nhiên chúng tôi cũng có thể thực hiện trên các phiên bản dành cho thiết bị di động.

Những điểm quan trọng cần làm nổi bật:

Các ứng dụng cơ bản trong ứng dụng dành cho máy tính để bàn: Như tôi đã đề cập trước đây, các ứng dụng này có một số tính năng, mặc dù chúng hoạt động trên thiết bị di động, ở đây có ý nghĩa hơn — ví dụ: tạo menu hoặc nhiều cửa sổ.

Hãy ghi nhớ điểm trước, đa cửa sổ là một chức năng sẽ hoạt động theo cùng một cách cho bất kỳ thiết bị và nền tảng nào , chỉ có điều là bạn có thể sẽ cảm nhận được nhiều lợi thế hơn khi sử dụng nó trong các ứng dụng máy tính để bàn hoặc các thiết bị như iPad lớn hơn .

Hãy chào đón nhiều cửa sổ! 🎊

.NET MAUI Đa Windows

Thêm cài đặt nền tảng cần thiết

Để triển khai nhiều cửa sổ, hãy làm theo hướng dẫn bên dưới:

Logo của AppleiOS và macOS

Hãy bắt đầu với Info.plist:

➖ Nhấp vào Thư mục Nền tảng
➖ Nhấp vào Thư mục iOS hoặc MacCatalyst (bạn phải thực hiện từng bước trên Nền tảng này)
➖ Info.plist
➖ Để mở: Nhấp đúp hoặc nhấp vào Mở bằng… và chọn công cụ

Mở Info.plist theo các bước được liệt kê ở trên.

Khi bạn mở tệp, hãy áp dụng các bước sau:

Bước 1: Thêm Tệp kê khai cảnh ứng dụng. Sau khi thêm vào, bạn sẽ có kết quả như hình sau.
Bước 1

Bước 2: Đặt Bật nhiều Windows với CÓ.
Bước 2

Bước 3: Thêm Vai trò Phiên ứng dụng. Sau khi thêm vào, bạn sẽ có kết quả như hình sau.
Bước 3

Bước 4: Cuối cùng, hãy thêm những điều sau:

  • Ủy quyền Tên lớp với giá trị SceneDelegate .
  • Tên cấu hình có giá trị MAUI_DEFAULT_SCENE_CONFIGURATION .

Hoàn thành tất cả các bước trong Info.plist của bạn sẽ cho bạn một kết quả như sau.

Bước 4

Nếu bạn mở nó trong một trình soạn thảo văn bản, phần này của Info.plist của bạn sẽ trông giống như sau:

<key>UIApplicationSceneManifest</key>
    <dict>
     <key>UIApplicationSupportsMultipleScenes</key>
     <true/>
         <key>UISceneConfigurations</key>
     <dict>
    <key>UIWindowSceneSessionRoleApplication</key>
    <array>
	    <dict>   
		    <key>UISceneDelegateClassName</key>		    
		    <string>SceneDelegate</string>		    
		    <key>UISceneConfigurationName</key>		    
		    <string>__MAUI_DEFAULT_SCENE_CONFIGURATION__</string>    
	    </dict>
    </array>
</dict>
</dict>

Cuối cùng, hãy thêm lớp SceneDelegate.

Trong cùng một Thư mục iOS:

➖ Tạo lớp
SceneDelegate ➖ Đăng ký một SceneDelegate với [Register("SceneDelegate")]
➖ Kế thừa từ MauiUISceneDelegatelớp

Kết quả sẽ giống như ví dụ mã sau:

using Foundation;
using Microsoft.Maui;

namespace MultiWindowsSample;

[Register("SceneDelegate")]
public class SceneDelegate : MauiUISceneDelegate
{

}

⚠ Áp dụng chính xác các bước tương tự trong Thư mục MacCatalyst .

Windows và Android

Logo AndroidĐối với Android : Không yêu cầu cấu hình bổ sung.

Logo WindowsĐối với Windows : Không yêu cầu cấu hình bổ sung.

Tìm hiểu thêm về Multi-Windows

Đa cửa sổ giúp bạn mở tất cả các cửa sổ bạn cần trong ứng dụng của mình. Chức năng này đã được công bố trong Bản xem trước 11 của .NET MAUI .

Tôi sẽ giải thích hai phương pháp quan trọng và cơ bản nhất để xử lý các cửa sổ của chúng ta, đó là Mở và Đóng cửa sổ — hãy cùng xem!

🔓 Mở Windows

Hãy trình bày chi tiết phương thức OpenWindows , được cấu tạo bởi những thứ sau:

  • Lớp ứng dụng : có sẵn, Microsoft.Maui.Controltheo sau là .Current đề cập đến phiên bản của Ứng dụng hiện đang chạy.
  • Phương thức OpenWindows : chịu trách nhiệm mở cửa sổ, nó mong đợi một Đối tượng Cửa sổ.

Giải thích bằng hình ảnh sẽ như sau:

Cấu trúc OpenWindows

Hãy xem nó trong mã:

void OnOpenWindowClicked(object sender, EventArgs e)
{
     Application.Current.OpenWindow(new Window(new MainPage()));
}

🔒 Đóng Windows

Hãy trình bày chi tiết phương thức CloseWindows , được tạo bởi như sau:

  • Ứng dụngHiện tại có cùng định nghĩa như điểm trước.
  • Phương thức CloseWindows chịu trách nhiệm đóng cửa sổ; nó mong đợi một Đối tượng Cửa sổ.
  • GetParentWindows : Điều này giúp bạn lấy phần tử mẹ của một trang. Điều quan trọng cần biết là tất cả các Trang đều chứa phương thức này.

Hãy xem nó trong mã:

void OnCloseWindowClicked(object sender, EventArgs e)
{
    var window = GetParentWindow();
    if (window is not null)
    Application.Current.CloseWindow(window);
}

XAML

<ScrollView>

    <VerticalStackLayout Spacing="25" VerticalOptions="Center">
    
	    <Image Source="dotnet_bot.png"
		       HeightRequest="200"
			   HorizontalOptions="Center" />
    
	    <Label Text="Let's explore Multi-Windows in .NET MAUI!"
		       FontSize="25"
		       HorizontalOptions="Center" />
    
	    <Button Text="Open Windows"
		        Clicked="OnOpenWindowClicked"
		        HorizontalOptions="Center" />
    
	    <Button Text="Close Windows"
		        Clicked="OnCloseWindowClicked"
			    HorizontalOptions="Center" />
    
    </VerticalStackLayout>
    
</ScrollView>

Cuối cùng, đây là kết quả tuyệt vời của chúng tôi! 😍

Hoạt ảnh MultiWindows

Và, hãy xem qua macOS. 😍

trang trại

Gói (lại

Cảm ơn vì đã đọc! Hẹn gặp lại các bạn trong những bài viết tiếp theo! 🙋‍♀️

Liên kết: https://www.telerik.com/blogs/exploring-multi-windows-dotnet-maui

#dotnet #dotnetmaui #csharp 

What is GEEK

Buddha Community

Khám Phá đa Windows Trong .NET MAUI
Einar  Hintz

Einar Hintz

1602560783

jQuery Ajax CRUD in ASP.NET Core MVC with Modal Popup

In this article, we’ll discuss how to use jQuery Ajax for ASP.NET Core MVC CRUD Operations using Bootstrap Modal. With jQuery Ajax, we can make HTTP request to controller action methods without reloading the entire page, like a single page application.

To demonstrate CRUD operations – insert, update, delete and retrieve, the project will be dealing with details of a normal bank transaction. GitHub repository for this demo project : https://bit.ly/33KTJAu.

Sub-topics discussed :

  • Form design for insert and update operation.
  • Display forms in modal popup dialog.
  • Form post using jQuery Ajax.
  • Implement MVC CRUD operations with jQuery Ajax.
  • Loading spinner in .NET Core MVC.
  • Prevent direct access to MVC action method.

Create ASP.NET Core MVC Project

In Visual Studio 2019, Go to File > New > Project (Ctrl + Shift + N).

From new project window, Select Asp.Net Core Web Application_._

Image showing how to create ASP.NET Core Web API project in Visual Studio.

Once you provide the project name and location. Select Web Application(Model-View-Controller) and uncheck HTTPS Configuration. Above steps will create a brand new ASP.NET Core MVC project.

Showing project template selection for .NET Core MVC.

Setup a Database

Let’s create a database for this application using Entity Framework Core. For that we’ve to install corresponding NuGet Packages. Right click on project from solution explorer, select Manage NuGet Packages_,_ From browse tab, install following 3 packages.

Showing list of NuGet Packages for Entity Framework Core

Now let’s define DB model class file – /Models/TransactionModel.cs.

public class TransactionModel
{
    [Key]
    public int TransactionId { get; set; }

    [Column(TypeName ="nvarchar(12)")]
    [DisplayName("Account Number")]
    [Required(ErrorMessage ="This Field is required.")]
    [MaxLength(12,ErrorMessage ="Maximum 12 characters only")]
    public string AccountNumber { get; set; }

    [Column(TypeName ="nvarchar(100)")]
    [DisplayName("Beneficiary Name")]
    [Required(ErrorMessage = "This Field is required.")]
    public string BeneficiaryName { get; set; }

    [Column(TypeName ="nvarchar(100)")]
    [DisplayName("Bank Name")]
    [Required(ErrorMessage = "This Field is required.")]
    public string BankName { get; set; }

    [Column(TypeName ="nvarchar(11)")]
    [DisplayName("SWIFT Code")]
    [Required(ErrorMessage = "This Field is required.")]
    [MaxLength(11)]
    public string SWIFTCode { get; set; }

    [DisplayName("Amount")]
    [Required(ErrorMessage = "This Field is required.")]
    public int Amount { get; set; }

    [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
    public DateTime Date { get; set; }
}

C#Copy

Here we’ve defined model properties for the transaction with proper validation. Now let’s define  DbContextclass for EF Core.

#asp.net core article #asp.net core #add loading spinner in asp.net core #asp.net core crud without reloading #asp.net core jquery ajax form #asp.net core modal dialog #asp.net core mvc crud using jquery ajax #asp.net core mvc with jquery and ajax #asp.net core popup window #bootstrap modal popup in asp.net core mvc. bootstrap modal popup in asp.net core #delete and viewall in asp.net core #jquery ajax - insert #jquery ajax form post #modal popup dialog in asp.net core #no direct access action method #update #validation in modal popup

Using Windows Forms DataGridView in .NET Core 3.1

How to use Windows Forms DataGridView on .NET Core.

#.net #windows #windows forms datagridview #.net core 3.1 #.net core #programming

Eric  Bukenya

Eric Bukenya

1618666860

.NET Conf 2020 Demos & Sessions for .NET 5 + Virtual Events!

This year’s .NET Conf was the largest one yet, with over 80 live sessions across three days that were co-organized and presented by the .NET community and Microsoft. On top of all of that, it also marked the release of .NET 5.0  that brings a full set of new capabilities, performance gains, and new languages features for developers to create amazing apps. If you missed this year’s .NET Conf live stream, don’t worry because we have you covered!

#.net #.net core #asp.net #c# #.net conf #.net foundation #community #demos

Aisu  Joesph

Aisu Joesph

1624386660

.NET News Roundup: .NET 6, MAUI, EF Core 6, Visual Studio 2022

It’s been a busy week for the .NET community with the release of new previews for .NET 6 and its related frameworks (including MAUI), along with the first preview of Visual Studio 2022, new Azure SDK libraries, and more. InfoQ examined these and a number of smaller stories in the .NET ecosystem from the week of June 14th, 2021.

This week’s highlight was the release of new previews for .NET 6 and its related frameworks. .NET 6 Preview 5 includes improvements to a new feature named SDK workloads, which - according to Richard Lander, program manager for the .NET team at Microsoft - is the foundation of the .NET unification vision. The new feature allows developers to add support for new application types (such as mobile and WebAssembly) without increasing the size of the SDK. The improvements to the new feature are the inclusion of two new verbs - list and update - providing a sense of the expected final experience with the general availability release in November. Other features in .NET 6 Preview 5 include NuGet package validationmore Roslyn analyzers, improvements in the Microsoft.Extensions APIs (focused on hosting and dependency injection), WebSocket compression, and much more. Also according to Lander, “.NET 6 Preview 5 is perhaps the biggest preview yet in terms of breadth and quantity of features.” A comprehensive list of all features included in the new preview can be found in the official release post.

The ASP.NET Core framework also received significant improvements in .NET 6 Preview 5. One of the most important features of this release is the reduced Blazor WebAssembly download size with runtime relinking. Now developers can use the .NET WebAssembly tools (the same tools also used for .NET WebAssembly AOT compilation) to relink the runtime and remove unnecessary logic, dramatically reducing the size of the runtime. According to Microsoft, the size reduction is particularly relevant when using invariant globalization mode. Other features in the new release include .NET Hot Reload updates for dotnet watch, faster get and set for HTTP headers, and ASP.NET Core SPA templates updated to Angular 11 and React 17.

#azure #.net #.net maui #visual studio 2019 #.net 6 #visual studio 2022 #devops #news

Windows Forms Designer for .NET Core Released | .NET Blog

Today we’re happy to announce that the Windows Forms designer for .NET Core projects is now available as a preview in Visual Studio 2019 version 16.6! We also have a newer version of the designer available in Visual Studio 16.7 Preview 1!

#.net #windows forms designer #.net core #.net blog #programming