Hi,
I'm trying Building a very simple cross-plaform app - for all three platforms - that can show an image - that is stored on the phone - in a Image control. My app have two pages:
- The main page that is a ListView containg list of Entry elements also containing a "New Entry" button that opens the next page:
- A Entry page where I have a simpel Entry field (where typing just something :-) ) and a Image control
To start with I make this very simple and for the test purpose I just read one image from the Picture library where the path is hard-coded.
Scenario:
1. From my Main page I click the "New Entry" opening the Entry Page
2. Since the Image is hard-coded it will already show the image from my Library (Works fine)
3. Fill out the Title and click the back button
4. The new entry is now in my list on my Main Page.
5. Click the created entry from the list and the Entry page opens and showing the data that was entered in step 3. (and also showing the image Again with no problem)
6. Click the "Back button" .. back to the Main Page
7. Repeat 5. and 6. two more times ..
-> the App will crash.
This code is based on the example from the "Creating Mobile Apps with Xamarin.Forms" (as you can guess :-) ). Here is a bit of the "Entry Page":
``class EntryPage : ContentPage
{
private EntryNote entryNote;
private bool editMode;
public EntryPage(EntryNote entryNote, bool editMode = false)
{
this.entryNote = entryNote;
this.editMode = editMode;
Title = "New Entry";
// Title Field
Entry entry = new Entry
{
Placeholder = "Title"
};
// Image Box
Image imageBox = new Image
{
Source = FileImageSource.FromFile(this.entryNote.ImageSrc), // ImageSrc is a string and hard-coded to a path on my Android phone (found when debugging)
Aspect = Aspect.AspectFit
};
this.BindingContext = this.entryNote;
entry.SetBinding(Entry.TextProperty, "Title");
StackLayout stackLayout = new StackLayout
{
Children =
{
new Label { Text = "Title:" },
entry,
imageBox
}
};
this.Content = stackLayout;
}
protected override void OnDisappearing()
{
this.ToolbarItems.Clear();
if (!String.IsNullOrWhiteSpace(expense.Title))
{
if (!this.editMode)
{
App.EntryFolder.Entries.Add(this.entryNote);
}
}
base.OnDisappearing();
}
}
}``
I'm running this on my Samsung Galaxy S4 Mini .. but not tried it on iPhone yet. On WP I in general have problem showing images that is stored on the phone .. e.g. form the Camera Roll Library
/Per