0

Is there a way in InkCanvas to insert an image that would be movable, selectable and resizable?

EDIT: My try:

private void AddButton_Click(object sender, RoutedEventArgs e)
{
    Image image = new Image
    {
        Width = 100,
        Source = new BitmapImage(new Uri("phone.jpg", UriKind.Relative))
    };
    InkCanvas.Children.Add(image);
}

But in the inkcanvas is not displaying anything at all. And don't know if this approach would be editable at all.

Dracke
  • 651
  • 2
  • 11
  • 30
  • @Clemens added not working try – Dracke May 04 '15 at 14:32
  • Should work, provided that there is an image file phone.jpg in the application's current directory. Better add the image file to your Visual Studio project, set its Build Action to Resource, and use `new Uri("pack://application:,,,/phone.jpg")`. And of course it wouldn't be movable or resizable out of the box. – Clemens May 04 '15 at 14:40
  • I added the phone.jpg into the solution. The project is called SmartIWall and so I tried the uri `Source = new BitmapImage(new Uri(@"pack://SmartIWall/phone.jpg"))` but it gives me an exception of wrong Uri. – Dracke May 04 '15 at 14:52
  • See [Pack URIs in WPF](https://msdn.microsoft.com/en-us/library/aa970069.aspx#Resource_File_Pack_URIs___Local_Assembly). The Uri has to be `pack://application:,,,/phone.jpg`, literally. – Clemens May 04 '15 at 14:54
  • Well now on the `new Image` line it says `'System.NotSupportedException' occurred in PresentationCore.dll` – Dracke May 04 '15 at 14:59
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/76902/discussion-between-dracke-and-clemens). – Dracke May 04 '15 at 15:02

0 Answers0