This is a migrated thread and some comments may be shown as answers.

Binding RadMosaicHubTile ImageSources

13 Answers 160 Views
HubTile
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel Knoll
Top achievements
Rank 1
Daniel Knoll asked on 23 Apr 2012, 04:30 PM
Hi,

I'm using the HubTiles in an MVVM environment.

I'd like to bind the ImageSources Property of the RadMosaicHubTile to a list of strings, to have different pictures shown when having different data. Unfortunately the ImageSources can't be bound. Is there an other approach for this?

Greets

13 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Stanoev
Telerik team
answered on 24 Apr 2012, 02:48 PM
Hello David,

Currently this scenario is not supported. You will have to manually insert the strings inside the ImageSources property. Sorry for the inconvenience caused.

Kind regards,
Kiril Stanoev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Kiril Stanoev
Telerik team
answered on 24 Apr 2012, 03:03 PM
Hi David,

 A quick follow up on the matter. I've discussed your scenario with our development team and binding the ImageSources property will be available and supported with our next internal build. 

Greetings,
Kiril Stanoev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Daniel Knoll
Top achievements
Rank 1
answered on 25 Apr 2012, 04:29 PM
Hi,

thanks for your answer and the good news. Seems to be the second reason to look forward to downloading a new build ;)

Greets
0
Daniel Knoll
Top achievements
Rank 1
answered on 03 May 2012, 07:01 AM
Hi,

I tried the internal build and the Property is visible in XAML to be bound. However, if I bind the Property to my ViewModel, I receive following error when I initialize the view:

Value can not be null.
Parameter name: ImageSources cannot be null.

What's wrong there?
0
Victor
Telerik team
answered on 03 May 2012, 08:31 AM
Hello David,

Thanks for the question.
This exception is raised by the base of class RadMosaicHubTile (PictureHubTile) because it does not allow the ImageSources property to be set to null. You could avoid this very easily by always returning a valid collection object (it's ok for the collection to empty) from your ViewModel.
Since this behavior seems to be unfriendly, we will consider modifying PictureHubTile to work with a null collection.

Please write again if you have other questions.

Kind regards,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Daniel Knoll
Top achievements
Rank 1
answered on 03 May 2012, 12:01 PM
Hi,

thanks for your answer.
It seems to work with an empty collection, but it has to be an ObservableCollection<string>, a standard List<string> Collection will not work, because there seems to be a problem with converting those two.

It would be definately be helpful if the Control will also work with a null value.

I'm also quite unhappy with the fact, that I have to provide a Uri for the picture. In my scenario I download the pictures from a Service and as a result I get a byte[] which I convert to ImageSources. Now I can't bind directly to the Collection of ImageSources. I cannot provide an Converter either, because it always needs a string array.
As a workaround I tried to bind to an Collection of IDs for the images so I can identify them and use a custom CreateImageSource method. But unfortunately I was not able to set the CreateImageSource method from XAML, and I can't bind it in my ViewModel. So I need to break the MVVM pattern by assigning the Method in code.

So the Control seems not to be very MVVM-friendly. Maybe you can use my feedback to have some enhancements.

Greets
0
Victor
Telerik team
answered on 03 May 2012, 02:31 PM
Hi David,

Thank you very much for the feedback.
We had a really difficult time figuring out what API to create for the image hub tiles. As it turns out, a collection of strings is not the best approach.
The change to the current API will be very simple and will not introduce a breaking change. We will simply change the ImageSources to be Collection<object> instead of Collection<string>. In this way, users can put whatever they want inside the collection and will be able to convert whatever objects they put inside via the CreateImageSouce callback property which is already present in the latest build. With the new changes you will be able to do this:

Collection<object> imageSources = new Collection<object>();
ImageSource image = GetImageFromWeb();
imageSources.Add(image);
 
RadMosaicHubTile hubTile = new RadMosaicHubTile();
hubTile.CreateImageSource = (source) =>
{
    return (ImageSource)source;
};
hubTile.ImageSources = imageSources;

Since in your case you directly have ImageSource objects. You just insert them in the ImageSources collection and then set the CreateImageSouce callback to a method that just casts the objects that come from the collection to ImageSource. When CreateImageSource is set back to null, the hub tile will simply assume that the objects are strings and interpret them as such.

These changes will be in effect in the next internal build.
Please write again if you need further assistance.

Kind regards,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Daniel Knoll
Top achievements
Rank 1
answered on 04 May 2012, 10:31 AM
Hi,

thanks for your reply and also thank you for your change in the API. I will try the new way as soon as the internal build is available.

Greets
0
Victor
Telerik team
answered on 07 May 2012, 09:00 AM
Hi David,

 I will notify you in this thread as soon as the internal build is available.

Regards,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Victor
Telerik team
answered on 10 May 2012, 09:18 AM
Hello David,

 I am happy to inform you that the new internal build is available. Feel free to try out the new hub tile API :).

Greetings,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Daniel Knoll
Top achievements
Rank 1
answered on 16 May 2012, 11:47 AM
Hi,

thanks. I tried it and it works like a charm :) . Thanks for modifying the API.

Greets
0
Brian Farnhill
Top achievements
Rank 1
answered on 27 May 2012, 02:54 PM
Hey guys,

I ran acorss this one as well and was able to reach a resolution using the latest internal build as well. Any idea when this is likely to make it in to a production release that I can use to publish an update to my app? A rough timeline will do, just to help with the planning on my end.

Thanks for pushing this fix in as well guys, being able to bind the image source for this control makes much more sense!

Cheers,

Brian
0
Victor
Telerik team
answered on 28 May 2012, 08:41 AM
Hi Brian,

We have not planned any internal builds until the official release which is on June 6th (next week).
Please write again if you have other questions.

Kind regards,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
HubTile
Asked by
Daniel Knoll
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Daniel Knoll
Top achievements
Rank 1
Victor
Telerik team
Brian Farnhill
Top achievements
Rank 1
Share this question
or