David Smith

David Smith

  • NA
  • 2k
  • 0

Silverlight UserControl for ImageSource is not loading for some reason

Nov 4 2011 5:11 PM

I after I created an instance of customerService object during user control loaded event, Image is not showing up, I have no ideal can some one assist me. Name value are showing up , but the images are not showing up, can someone help me.

 public class CustomerService
    {
        /// <summary>
        /// method returns a collection of customers
        /// </summary>
        /// <returns></returns>
        public static List<CustomerManager> GetCustomers()
        {
            return new List<CustomerManager>
            {
                new CustomerManager{
                                Name="Keith",
                                ImageSource="Images/men.png",
            
 
                            },
                new CustomerManager
                            {
                                Name="Tina",
                                ImageSource="Images/woman.png",
                            },
 
            };
        }
    }

  public partial class TestControl : UserControl
    {
        List<CustomerManager> customers = null;

        public TestControl()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(TestControl_Loaded);
        }

        void TestControl_Loaded(object sender, RoutedEventArgs e)
        {

           /lbCustomer.ItemsSource = from c in CustomerService.GetCustomers()
                                   select new CustomerManager
                                    {
                                        ImageSource = c.ImageSource,
          
                                        Name = c.Name,
                                    };



        }
    }

-----------------------------------------------------------------------------------

      <ListBox x:Name="lbCustomer" Style="{StaticResource ListBoxBackground}"  Background="{x:Null}" Width="150" Height="370">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" >
                                <TextBlock Text="{Binding Name}" Foreground="YellowGreen" FontSize="14" />
                                <StackPanel>
                                <Image Height="75" Width="75" VerticalAlignment="Top" Margin="0,10,8,0" Source="{Binding ImageSource}" />
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

     public static List<CustomerManager> GetCustomers()

Answers (1)