none
Can someone give me an example of how to set an image?

    Question

  • hi,

    I'm trying to set an image in my code, but it doesn't seem to work. Can someone give me a simple .xaml and .cs of how to set an image. Mine look like this...
    .xaml:
    <Window
        xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
        xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
        Title="TrackingApplication" Width="953" Height="753">
        <TabPanel>
            <TabControl Width="400" Height="500">
          <TabItem Width="90" Height="20" Header="MapView">
              <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                <Image Name="Map" Width="350" Height="400">
                </Image>
              </Grid>
          </TabItem>
                <TabItem Width="90" Height="20" Header="PolygonInfo">Two</TabItem>
                <TabItem Width="90" Height="20" Header="ExtraTab">Three</TabItem>
                <TabItem Width="90" Height="20" Header="ExtraTab">Four</TabItem>
            </TabControl>
        </TabPanel>
    </Window>

    .cs:
    private MapImage renderMap(LatLong myLLC)
            {
                // at this point VS doesn't seem to know Map so I set it myself, but that doesn't work
                Map.Source(new Bitmap(new                        
                    System.IO.MemoryStream(myMapImages[0].MimeData.Bits)));
            }
    Thursday, February 16, 2006 9:11 AM

Answers

  • Doh! I meant to say:

    Map.Source = BitmapFrame.Create(new System.IO.MemoryStream(myMapImages[0].MimeData.Bits)));
    Thursday, February 16, 2006 3:58 PM
    Moderator

All replies

  • Notice the fix to the C# code…












    Two
    Three
    Four




    .cs:
    private MapImage renderMap(LatLong myLLC)
    {
    // at this point VS doesn't seem to know Map so I set it myself, but that doesn't work
    Map.Source = new BitmapFrame(new
    System.IO.MemoryStream(myMapImages[0].MimeData.Bits)));
    }
    Thursday, February 16, 2006 3:08 PM
    Moderator
  • At first, thanks for the reply.

    At second, now I'm getting this error:
    Error    11    Cannot create an instance of the abstract class or interface 'System.Windows.Media.Imaging.BitmapFrame'

    At the top I have typed the following lines
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
    using TrackingApplication.net.mappoint.staging;
    using System.Configuration;
    using System.Net;
    using System.Drawing;

    is there something else needed to make it work?

    Thursday, February 16, 2006 3:25 PM
  • Doh! I meant to say:

    Map.Source = BitmapFrame.Create(new System.IO.MemoryStream(myMapImages[0].MimeData.Bits)));
    Thursday, February 16, 2006 3:58 PM
    Moderator
  • Thank you very much Mr. Wlodarczyk

    Thursday, February 16, 2006 4:03 PM