TAGS :Viewed: 5 - Published at: a few seconds ago

[ wp8 binding when click button ]

I just want to make binding with my list box when i click the button.
This is my code in file .cs

      private void Button_Click_1(object sender, RoutedEventArgs e)
            user_info = user_data.Text.Trim();
           words= user_info.Split(' ');

           foreach (string word in words)
               letters = word.ToCharArray();

               for (int i = 0; i < letters.Length; i++)
                  string s = letters[i] + ".jpg";

                   souce_data.Add(new input_data(s));                       
               phoronic_name.DataContext = souce_data;

and this is my list box

  <ListBox x:Name="phoronic_name" SelectionChanged="phoronic_name_SelectionChanged" Foreground="Orange" >


                    <StackPanel Orientation="Horizontal" >                     

                       <TextBlock Padding="3,0,3,0"
                  Text="{Binding letters}" FontSize="{StaticResource PhoneFontSizeSmall}"/>
                       <Image Source="{Binding souce_data}" Height="80" Width="80"/>


But when I click the button, there is no data

Answer 1

So 'souce_data' is the collection you want to bind.
Put it as ItemSource of Listbox instead of DataContext

    private void Button_Click_1(object sender, RoutedEventArgs e)
       //your code