locked
load image RRS feed

  • Question

  • I am developing a silverlight app.
    I need load a image on loacal machine to app.\
    how can I do this?
    thanks
    Wednesday, July 2, 2014 9:38 AM

Answers

  • Hi,

    I have created a sample to read a local image in a silverlight imageBox. Please try to check it:

    In the MainPage.xaml:

    <Grid x:Name="LayoutRoot" Background="White">
            <Image Name="image1" HorizontalAlignment="Left" Height="152" Margin="74,40,0,0" VerticalAlignment="Top" Width="231"/>
            <Button Background="Red" Content="load image" HorizontalAlignment="Left" Margin="126,212,0,0" VerticalAlignment="Top" Width="117" Height="46" Click="Button_Click"/>
        </Grid>

    In the MainPage.xaml.cs:

    public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                OpenFileDialog openfile = new OpenFileDialog();
                bool? IsSeletected = openfile.ShowDialog();
                if(IsSeletected==true)
                {
                    BitmapImage bitImage = new BitmapImage();
                    bitImage.SetSource(openfile.File.OpenRead());
                    image1.Source = bitImage;
                }
            }
       }

    Besides, the link below will give you some help:

    http://www.c-sharpcorner.com/uploadfile/mahesh/display-image-in-silverlight/

    Best Regards,
     


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    • Marked as answer by Jonny_D Thursday, July 10, 2014 1:12 AM
    Thursday, July 3, 2014 2:34 AM

All replies

  • Hi youjojoj23, you can read these helpful threads:

    Displaying local images.

    Silverlight - Showing images.

    Best regards


    Christian Amado | Software Engineer | MCPD: Windows Phone Developer | MCTS: Silverlight Developer

    Wednesday, July 2, 2014 1:11 PM
  • Hi,

    I have created a sample to read a local image in a silverlight imageBox. Please try to check it:

    In the MainPage.xaml:

    <Grid x:Name="LayoutRoot" Background="White">
            <Image Name="image1" HorizontalAlignment="Left" Height="152" Margin="74,40,0,0" VerticalAlignment="Top" Width="231"/>
            <Button Background="Red" Content="load image" HorizontalAlignment="Left" Margin="126,212,0,0" VerticalAlignment="Top" Width="117" Height="46" Click="Button_Click"/>
        </Grid>

    In the MainPage.xaml.cs:

    public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                OpenFileDialog openfile = new OpenFileDialog();
                bool? IsSeletected = openfile.ShowDialog();
                if(IsSeletected==true)
                {
                    BitmapImage bitImage = new BitmapImage();
                    bitImage.SetSource(openfile.File.OpenRead());
                    image1.Source = bitImage;
                }
            }
       }

    Besides, the link below will give you some help:

    http://www.c-sharpcorner.com/uploadfile/mahesh/display-image-in-silverlight/

    Best Regards,
     


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    • Marked as answer by Jonny_D Thursday, July 10, 2014 1:12 AM
    Thursday, July 3, 2014 2:34 AM