Adding Images to Resource in WPF


To display image in your application you need to add your images to resource with you folder path where the images exist.

Syntax for adding images to resource

<BitmapImage x:Key="KeyName" UriSource="ImagePath"/>




    <BitmapImage x:Key="Connected" UriSource="/Image/connected.png"/>

    <BitmapImage x:Key="Disconnected" UriSource="/Image/disconnected.png"/>

    <BitmapImage x:Key="Login" UriSource="/Image/login.png"/>

    <BitmapImage x:Key="Logout" UriSource="/Image/logout-b.png"/>



Above code is for adding images to resource.

Code for use resource in image control

<Image Stretch="Uniform" DockPanel.Dock="Top" Source="Image/Fill.png" ></Image>