Inserting Images in a Window
I assume you are familiar with inserting images into a window using scripting and or framework design based languages but this article will provide you a touch of inserting images in a window using C#. You can select any type of image, in any format like:
- .jpg
- .jpeg
- .png
- .gif etc.
Functioning
The process of inserting images in a window is quite easy and simple. You only need to create several sets of file formats to be inserted.
Afterwards the procedure will follow like this-
- Initialization of the inserting procedure
- Applying a button from tools
- Creating a button click event on call
- Coding on that event
- Creating file picker
- Declaring image formats (depends)
- Call of that picker event
Procedure
There is no complexity in this application, what you only need to follow is basic operations of Visual Studio and knowledge of C#.NET. Here we go.
Step 1
- Open Visual Studio (any version)
- Create a .CS file
(for the C# code)
- The code in this page file is like this"
Step 2: Perform the actions required for it, like call, handling and so on.
Coding
The code will go like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public MainPage()
{
this.InitializeComponent();
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private async void button1_Click(object sender, RoutedEventArgs e)
{
FileOpenPicker openpicker = new FileOpenPicker();
openpicker.ViewMode = PickerViewMode.Thumbnail;
openpicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openpicker.FileTypeFilter.Add(".jpg");
openpicker.FileTypeFilter.Add(".jpeg");
openpicker.FileTypeFilter.Add(".png");
// picking file formats
StorageFile file = await openpicker.PickSingleFileAsync();
}