-->
- Mac Visual Studio 7.7.4 Blank Forms App Net Standard Disabled One
- Mac Visual Studio 7.7.4 Blank Forms App Net Standard Disabled Iphone
- Mac Visual Studio 7.7.4 Blank Forms App Net Standard Disabled Windows 10
- Mac Visual Studio 7.7.4 Blank Forms App Net Standard Disabled Free
Visual Studio 2019 for Mac. Develop apps and games for iOS, Android and using.NET. Download Visual Studio for Mac. Create and deploy scalable, performant apps using.NET and C# on the Mac. Open Visual Studio 2019. On the start window, choose Create a new project. On the Create a new project window, choose the Windows Forms App (.NET Framework) template for C#. (If you prefer, you can refine your search to quickly get to the template you want. For example, enter or type Windows Forms App.
Before attempting this tutorial, you should have successfully completed the:
- Build your first Xamarin.Forms app quickstart.
- StackLayout tutorial.
In this tutorial, you learn how to:
- Create a Xamarin.Forms
Image
in XAML. - Customize the
Image
appearance. - Display a local image file from each platform project.
You will use Visual Studio 2019, or Visual Studio for Mac, to create a simple application that demonstrates how to display an image and customize its appearance. The following screenshots show the final application:
Create a image
To complete this tutorial you should have Visual Studio 2019 (latest release), with the Mobile development with .NET workload installed. In addition, you will require a paired Mac to build the tutorial application on iOS. For information about installing the Xamarin platform, see Installing Xamarin. For information about connecting Visual Studio 2019 to a Mac build host, see Pair to Mac for Xamarin.iOS development.
- Launch Visual Studio, and create a new blank Xamarin.Forms app named ImageTutorial. Ensure that the app uses .NET Standard as the shared code mechanism.ImportantThe C# and XAML snippets in this tutorial requires that the solution is named ImageTutorial. Using a different name will result in build errors when you copy code from this tutorial into the solution.For more information about the .NET Standard library that gets created, see Anatomy of a Xamarin.Forms application in the Xamarin.Forms Quickstart Deep Dive.
- In Solution Explorer, in the ImageTutorial project, double-click MainPage.xaml to open it. Then, in MainPage.xaml, remove all of the template code and replace it with the following code:This code declaratively defines the user interface for the page, which consists of an
Image
in aStackLayout
. TheImage.Source
property specifies the image to display, via a URI. TheImage.Source
property is of typeImageSource
, which enables images to be sourced from files, URIs, or resources. For more information, see Displaying images in the Images in Xamarin.Forms guide.TheHeightRequest
property specifies the height of theImage
in device-independent units.NoteIt's not necessary to set theWidthRequest
property in this example. This is because, by default, theImage
maintains the aspect ratio of the image. - In the Visual Studio toolbar, press the Start button (the triangular button that resembles a Play button) to launch the application inside your chosen remote iOS simulator or Android emulator:NoteThe
Image
view automatically caches downloaded images for 24 hours. For more information, see Downloaded image caching in the Images in Xamarin.Forms guide.
To complete this tutorial you should have Visual Studio for Mac (latest release), with iOS and Android platform support installed. In addition, you will also require Xcode (latest release). For more information about installing the Xamarin platform, see Installing Xamarin.
- Launch Visual Studio for Mac, and create a new blank Xamarin.Forms app named ImageTutorial. Ensure that the app uses .NET Standard as the shared code mechanism.ImportantThe C# and XAML snippets in this tutorial requires that the solution is named ImageTutorial. Using a different name will result in build errors when you copy code from this tutorial into the solution.For more information about the .NET Standard library that gets created, see Anatomy of a Xamarin.Forms application in the Xamarin.Forms Quickstart Deep Dive.
- In Solution Pad, in the ImageTutorial project, double-click MainPage.xaml to open it. Then, in MainPage.xaml, remove all of the template code and replace it with the following code:This code declaratively defines the user interface for the page, which consists of an
Image
in aStackLayout
. TheImage.Source
property specifies the image to display, via a URI. TheImage.Source
property is of typeImageSource
, which enables images to be sourced from files, URIs, or resources. For more information, see Displaying images in the Images in Xamarin.Forms guide.TheHeightRequest
property specifies the height of theImage
in device-independent units.NoteIt's not necessary to set theWidthRequest
property in this example. This is because, by default, theImage
maintains the aspect ratio of the image. - In the Visual Studio for Mac toolbar, press the Start button (the triangular button that resembles a Play button) to launch the application inside your chosen iOS simulator or Android emulator:NoteThe
Image
view automatically caches downloaded images for 24 hours. For more information, see Downloaded image caching in the Images in Xamarin.Forms guide.
Customize appearance
- In MainPage.xaml, modify the
Image
declaration to customize its appearance:This code sets theAspect
property, which defines the scaling mode of the image, toFill
. TheFill
member is defined in theAspect
enumeration, and stretches the image to completely fill the view, regardless of whether the image is distorted. For more information about image scaling, see Displaying images in the Images in Xamarin.Forms guide.TheOnPlatform
markup extension enables you to customize UI appearance on a per-platform basis. In this example, the markup extension is used to set theHeightRequest
andWidthRequest
properties to 300 device-independent units on iOS and to 250 device-independent units on Android. For more information about theOnPlatform
markup extension, see OnPlatform markup extension in the Consuming XAML Markup Extensions guide.In addition, theHorizontalOptions
property specifies that the image will be horizontally centered. - In the Visual Studio toolbar, press the Start button (the triangular button that resembles a Play button) to launch the application inside your chosen remote iOS simulator or Android emulator:
- In MainPage.xaml, modify the
Image
declaration to customize its appearance:This code sets theAspect
property, which defines the scaling mode of the image, toFill
. TheFill
member is defined in theAspect
enumeration, and stretches the image to completely fill the view, regardless of whether the image is distorted. For more information about image scaling, see Displaying images in the Images in Xamarin.Forms guide.TheOnPlatform
markup extension enables you to customize UI appearance on a per-platform basis. In this example, the markup extension is used to set theHeightRequest
andWidthRequest
properties to 300 on iOS and to 250 on Android. For more information about theOnPlatform
markup extension, see OnPlatform markup extension in the Consuming XAML Markup Extensions guide.In addition, theHorizontalOptions
property specifies that the image will be horizontally centered. - In the Visual Studio for Mac toolbar, press the Start button (the triangular button that resembles a Play button) to launch the application inside your chosen iOS simulator or Android emulator:
Display a local image
Image files can be added to platform projects and referenced from Xamarin.Forms shared code. This method of distributing images is required when images are platform-specific, such as when using different resolutions on different platforms, or slightly different designs.
In this exercise, you will modify the ImageTutorial solution to display a local image, rather than an image downloaded from a URI. The local image is the Xamarin logo, which should be downloaded by clicking the button below.
Important
To use a single image across all platforms, the same filename must be used on every platform, and it should be a valid Android resource name (i.e. only lowercase letters, numerals, the underscore, and the period are allowed).
- In Solution Explorer, in the ImageTutorial.iOS project, expand Asset Catalogs, and double-click Assets to open it. Then, in the Assets.xcassets tab, click the Plus button and select Add Image Set:
- In the Assets.xcassets tab, select the new image set and the editor will be displayed:
- Drag XamarinLogo.png from your file system to the 1x box for the Universal category:
- In the Assets.xcassets tab, right-click the new image set's name and rename it to XamarinLogo:Save and close and Assets.xcassets tab.
- In Solution Explorer, in the ImageTutorial.Android project, expand the Resources folder. Then, drag XamarinLogo.png from your file system to the drawable folder:NoteVisual Studio will automatically set the build action for the image to AndroidResource.
- In the ImageTutorial project, in MainPage.xaml, modify the
Image
declaration to display the local XamarinLogo file:This code sets theSource
property to the local file to display. TheWidthRequest
property is set to 300 device-independent units on iOS, and 250 device-independent units on Android. In addition, theHorizontalOptions
property specifies that the image will be horizontally centered.NoteFor PNG images on iOS, the .png extension can be omitted from the filename specified in theSource
property. For other image formats, the extension is required. - In the Visual Studio for Mac toolbar, press the Start button (the triangular button that resembles a Play button) to launch the application inside your chosen iOS simulator or Android emulator:For more information about local images, see Local images in the Images in Xamarin.Forms guide.
- In Solution Pad, in the ImageTutorial.iOS project, double-click Assets.xcassets to open it. Then, in the Assets List, right-click and select New Image Set:
- In the Assets List, select the new image set and the editor will be displayed:
- Drag XamarinLogo.png from your file system to the 1x box for the Universal category:
- In the Assets List, double-click the new image set's name and rename it to XamarinLogo:
- In Solution Pad, in the ImageTutorial.Android project, expand the Resources folder. Then, drag XamarinLogo.png from your file system to the drawable folder.
- In the Add File to Folder dialog, select OK.NoteVisual Studio for Mac will automatically set the build action for the image to AndroidResource.
- In the ImageTutorial project, in MainPage.xaml, modify the
Image
declaration to display the local XamarinLogo file:This code sets theSource
property to the local file to display. TheWidthRequest
property is set to 300 device-independent units on iOS, and 250 device-independent units on Android. In addition, theHorizontalOptions
property specifies that the image will be horizontally centered.NoteFor PNG images on iOS, the .png extension can be omitted from the filename specified in theSource
property. For other image formats, the extension is required. - In the Visual Studio for Mac toolbar, press the Start button (the triangular button that resembles a Play button) to launch the application inside your chosen iOS simulator or Android emulator:For more information about local images, see Local images in the Images in Xamarin.Forms guide.
Congratulations!
Congratulations on completing this tutorial, where you learned how to:
- Create a Xamarin.Forms
Image
in XAML. - Customize the
Image
appearance. - Display a local image file from each platform project.
Next steps
To learn more about the basics of creating mobile applications with Xamarin.Forms, continue to the Grid tutorial.
Related links
Have an issue with this section? If so, please give us some feedback so we can improve this section.
-->.NET Standard libraries have a uniform API for all .NET Platforms including Xamarin and .NET Core. Create a single .NET Standard Library and use it from any runtime that supports the .NET Standard Platform. Refer to this chart for details of supported platforms.
While .NET Standard versions 1.0 through 1.6 provide incrementally larger subsets of the .NET Framework, .NET Standard 2.0 providesthe best level of support for Xamarin applications and for porting existing Portable Class Libraries.
Visual Studio for Mac
This section walks through how to create and use a .NET Standard Library using Visual Studio for Mac.
Creating a .NET Standard Library
You can add a .NET Standard Library to your solution with these steps:
- In the Add New Project dialog, select the .NET Core category and then select .NET Standard Library:
- On the next screen, choose the target framework - .NET Standard 2.0 is recommended:
- On the final screen, type the project name and click Create.
- The .NET Standard Library project will appear as shown in the Solution Explorer. The Dependencies node will indicate that the library uses the NETStandard.Library.
Editing .NET Standard Library settings
The .NET Standard Library settings can be viewed and changed by right-clicking on the project and selecting
Options
as shown in this screenshot:Inside you can change your version of
netstandard
by changing the Target Framework
dropdown value.Mac Visual Studio 7.7.4 Blank Forms App Net Standard Disabled One
Additionally: You can edit the
.csproj
directly to change this value.Visual Studio 2017 (Windows)
This section walks through how to create and use a .NET Standard Library using Visual Studio.
Creating a .NET Standard library
Adding a .NET Standard Library to your solution is fairly straight forward.
- In the New Project dialog, select the .NET Standard category and then select Class Library (.NET Standard).
- The .NET Standard Library project will appear as shown in the Solution Explorer. The Dependencies node will indicate that the library uses the NETStandard.Library.
Mac Visual Studio 7.7.4 Blank Forms App Net Standard Disabled Iphone
Editing .NET Standard library settings
Mac Visual Studio 7.7.4 Blank Forms App Net Standard Disabled Windows 10
The .NET Standard Library settings can be viewed and changed by right-clicking on the project and selecting Properties as shown in this screenshot:
Additionally: You can edit the
.csproj
directly to edit the TargetFramework
element and change which version is targeted (eg. <TargetFramework>netstandard2.0</TargetFramework>
).Using a .NET Standard Library project
Once a .NET Standard Library has been created, you can add a reference to it from any compatible Application or Library project in the same way you normally add references. In Visual Studio, right-click on the References node and choose Add Reference... then switch to the Projects > Solution tab as shown:
.NET Standard and Xamarin.Forms for the .NET Developer (video)
Related Links
Mac Visual Studio 7.7.4 Blank Forms App Net Standard Disabled Free
- .NET Standard - detailed information and comparison to PCL.