WPF Web Based

WPF Examples

WPF

WPF Projects

WPF Project

adplus-dvertising
Image Control in WPF Web Base
Previous Home Next

The Image control provides rich features to display images of various formats like JPEG, PNG, ICO, BMP, GIF etc. Displaying an image is as simple as setting the Image.Source property to the appropriate image file path. No special coding is required to work with different file formats.


Example:

.XAML CODE

<Page x:Class="WpfBrowserApplication6.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1" Loaded="Page_Loaded">
<Grid>
<Image Margin="8,9,0,0" Name="image1" Stretch="Fill" Height="231" 
       VerticalAlignment="Top" ImageFailed="image1_ImageFailed" 
       HorizontalAlignment="Left" Width="197" />
<Button Height="23" HorizontalAlignment="Right" Margin="0,22,12,0" 
       Name="button1" VerticalAlignment="Top" Width="75"
	   Click="button1_Click">Button</Button>
<Label Height="28" HorizontalAlignment="Right" Margin="0,64,12,0" 
       Name="label1" VerticalAlignment="Top" Width="75">Label</Label>
</Grid>
</Page>

.CS code:

private void Page_Loaded(object sender, RoutedEventArgs e)
{
image1.Source = new BitmapImage(new Uri("college-students-2.jpg",
	           UriKind.Relative));
}
Design Output:
Previous Home Next
WPF Examples

WPF

WPF

WPF

WPF

WPF

WPF

WPF

WPF