locked
how to pass these value into a new class and add an image for each string into the new class ? RRS feed

All replies

  • Hello!

    Create new class model with next properties:

    public class Provider
        {
            public string Name { get; set; }
    
            public string/*Uri*/ Logo { get; set; }
        }
    Next, create new List<Provider> and add images to every items. 


    Thursday, October 3, 2013 7:00 AM
  • and how do i pass those values into the new class ?

    19karabo91

    Thursday, October 3, 2013 10:13 AM
  • How do i pass the list of strings into the new class and add local images to each string? I'm really stuck here please help out.

    19karabo91

    Monday, October 7, 2013 9:29 AM
  • Hello!

    Where you get Supportedproviders.Provider collection?

    Monday, October 7, 2013 9:32 AM
  • I'm getting the list from a web service 

    19karabo91

    Monday, October 7, 2013 9:34 AM
  • It's your web service ?
    Monday, October 7, 2013 9:40 AM
  • its our company web service

    19karabo91

    Monday, October 7, 2013 9:50 AM
  • So why you don't send logos together with providers name ?

    Store images in your server and return web path to them.

    • Edited by Oleg Kurzov Monday, October 7, 2013 9:54 AM
    Monday, October 7, 2013 9:53 AM
  • I dont know why they did it like that ,they just told me that i have to attach an image related to the list of providers. 

    19karabo91

    Monday, October 7, 2013 9:55 AM
  • I recommend you to change "Provider" model in your web service and return images or some ProviderId. You can attach images by name, but what if they change names in service? Your app will broke.
    Monday, October 7, 2013 10:12 AM
  • So there's no other way i can achieve this without changing the Provider model from the web service?

    19karabo91

    Monday, October 7, 2013 10:36 AM
  • var supportedProviders = new List<string>
                {
                    "Google","Yahoo","Bing"//etc
                };
    
                var collectionWithImages = new ObservableCollection<Provider>();
                
                foreach (var provider in supportedProviders)
                {
                    Provider newProvider = null;
                    switch (provider)
                    {
                        case "Google": newProvider = new Provider { Name = provider, Logo = "google logo source" };
                            break; 
                        case "Yahoo":
                            newProvider = new Provider { Name = provider, Logo = "yahoo logo source" };
                            break;
                    }
                    if (newProvider != null)
                    {
                        collectionWithImages.Add(newProvider);
                    }
                }


    Monday, October 7, 2013 10:56 AM
  • Thanks this is exactly what i wanted .

    19karabo91

    Monday, October 7, 2013 12:22 PM