Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi,
I am working in Silverlight.

I have created two projects. One project contains user control. By giving reference, I am using that user control in my another project which also contains Image folder. Now, I want to use Image in my UserControl. How can i set it dynamically?

Here is my user control:

Xaml page:
<Image x:Name="imgDisplay" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Grid.Row="1" Grid.Column="1" Height="Auto" Width="Auto" Margin="0" Source="../Images/Email.png" />


Xaml.cs page:

public partial class exTile : UserControl
    {
        
        public ImageSource ImagePath
        {
            get { return imgDisplay.Source; }

            set
            {
                this.imgDisplay.Source = value;
            }
        }

    }



My page where i have used my UserControl and named as objTilesEmail.

exTile objTilesEmail = new exTile();
objTilesEmail.ImagePath = new System.Windows.Media.Imaging.BitmapImage(newUri("../Image/Email.png",UriKind.Relative));
Posted
Updated 23-Nov-11 22:05pm
v2
Comments
Sergey Alexandrovich Kryukov 24-Nov-11 2:37am    
Not until you provide some code sample. It should be comprehensive but minimalistic.
--SA
Savalia Manoj M 24-Nov-11 4:12am    
Will you please check this code now and give any suggestion?

Thanks in advance..

1 solution

You can try this...


exTile objTilesEmail = new exTile();
objTilesEmail.ImagePath = new System.Windows.Media.Imaging.BitmapImage (new Uri("/Repairs;component/Themes/PurpleTheme/Images/Email.png", UriKind.Relative));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900