Bug 17892 - MT.D Can't assign an image to a StringElement or StyledStringElement when loading from a JSON file.
Summary: MT.D Can't assign an image to a StringElement or StyledStringElement when loa...
Status: NEW
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: 7.0.2.x
Hardware: Macintosh Mac OS
: --- enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-02-19 15:51 UTC by Jon Goldberger [MSFT]
Modified: 2014-02-19 16:06 UTC (History)
1 user (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Comment 1 Jon Goldberger [MSFT] 2014-02-19 16:06:06 UTC
Working from the MonoTouch.Dialog sample app.

I see no way to add an image to an element in the .JSON file that is used to load the JSON sample page, nor can I easily add an image to an element after the JSON is loaded since the view has not been created yet, and even once it is created. there is not a way that I can see to modify the elements as the entire interface is created from the JSON file, so there is no DialogViewController class that can be edited in code to modify the Elements once they are displayed.  

I do see that you can add a background image or a BooleanElement on/off image, but not the left aligned image that is part of the UITableViewCell.Default, UITableViewCell.Subtitle, or UITableViewCell.Value1 cell styles that the StringElement or StyledStringElement uses. 

In Main.cs of the sample app, I tried looping through the elements of the Strings section by adding an ID, "stringElements", to the section in the sample.json file with:

// Lookup elements by ID:

var jsonSection = sampleJson ["stringElements"] as Section;
Console.WriteLine ("The section has {0} elements", jsonSection.Count);
foreach (StringElement el in jsonSection) {
    if (el.Caption == "Plain label" || el.Caption == "Plain label with value: " || el.Caption == "Styled label with subtitles") {
        Console.WriteLine("JsonElement: {0}", el.Summary());

While the above does get me to the relevant elements created from the sample.json file, there is no image or imageUri property in any of the Element classes that I can use to set an image, and I can't get to the underlying cell to set its image as the cells have not been created yet. 

There very well might be a way to do this that I am unaware of, but it still would be convenient to be able to set an image, or imageUri, in the JSON file just as you can set a background image or BooleanElement image.

Note You need to log in before you can comment on or make changes to this bug.