Inserting Images in a Window

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.


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


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)

    CS file

  • The code in this page file is like this"


Step 2: Perform the actions required for it, like call, handling and so on.


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()




/// <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;




    // picking file formats

    StorageFile file = await openpicker.PickSingleFileAsync();


Up Next
    Ebook Download
    View all
    View all