.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> WPF >> Post New QuestionBookmark and Share Subscribe to Forum

my task is dynamically show images

Posted By: Rajesh     Posted Date: July 06, 2012    Points:5   Category :WPF
my task is dynamically show images, i have used in array technique(Example total 7 images)display 4images in image button u have any btn click remaining 3image show the same imagebutton how? i have try it but some issue attached in sample apllication
C# code.....
/////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace explorer
{

public partial class merchancupon : Window
{
string[] imgs = new string[] { "coupon11.jpg", "Plane01.jpg", "Coupon22.jpg", "Plane01.jpg", "Plane02.jpg", "Plane03.jpg", "Coupon4.jpg" };
public int count;

public int imagvalue = 0;
public merchancupon()
{
InitializeComponent();
}



private void showImage(string img, int i)
{

imagvalue = imagvalue + 1;
BitmapImage b1 = new BitmapImage();
b1.BeginInit();
b1.UriSource = new Uri(img, UriKind.Relative);
b1.EndInit();
if (imagvalue == 1)
{
image1.Stretch = Stretch.Fill;
image1.Source = b1;
image1.Source = b1;
}
else if (imagvalue == 2)
{
image2.Stretch = Stretch.Fill;
image2.Source = b1;
image2.Source = b1;
}
else if (imagvalue == 3)
{
image3.Stretch = Stretch.Fill;
image3.Source = b1;
image3.Source = b1;
}
else if (imagvalue == 4)
{
image4.Stretch = Stretch.Fill;
image4.Source = b1;
image4.Source = b1;
}

}

private void Window_Loaded(object sender, RoutedEventArgs e)
{

foreach (string item in imgs)
{


showImage(item,0);



}
}

}
}
}


XAML Code ...........

<Window x:Class="explorer.merchancupon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="merchancupon" Height="429" Width="523" Loaded="Window_Loaded">
<Grid>


<!--<StackPanel Name="ss" >-->
<Image Height="164" x:Name="image1" Margin="38,6,291,208" Stretch="Fill" Width="172" />
<Image Height="164" x:Name="image2" HorizontalAlignment="Left" Margin="263,6,0,0" Stretch="Fill" VerticalAlignment="Top" Width="190" />
<Image Height="150" x:Name="image3" HorizontalAlignment="Left" Margin="38,173,0,0" Stretch="Fill" VerticalAlignment="Top" Width="172" />
<Image Height="150" x:Name="image4" HorizontalAlignment="Left" Margin="255,172,0,0" Stretch="Fill" VerticalAlignment="Top" Width="190" />
<Button Content="Next" Height="23" HorizontalAlignment="Left" Margin="365,355,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<!--</StackPanel>-->
</Grid>
</Window>


Responses

No response found. Be the first to respond this post
Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend