Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ListBox
Hi ,
I want to Bind ListBox in windows phone .
i tried  possible code but didn't get success.
can any one help me ,what mistake i did in this code , Please check once
 
.Xaml Code
 
 <controls:PanoramaItem Header="item1">
                <Grid>
                    <ListBox x:Name="listBox1">
                        <ListBox.ItemTemplate >
                            <DataTemplate>
                                <StackPanel Width="400" Margin="20" >
                                    <Button x:Name="pic"  Tag="{Binding StoreID}">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <TextBlock Text="{Binding Address1}" TextWrapping="Wrap" FontFamily="Arial" FontSize="28" Tag="{Binding StoreID}"/>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>
                                    <TextBlock Text="{Binding StoreID}" TextWrapping="Wrap" FontSize="24"/>
                                    <Image Source="{Binding source_icon}" Width="100" Height="60"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
 
                </Grid>
            </controls:PanoramaItem>
 

 
and .CS code
 

ObservableCollection<YSP_StoreInfoList> _StoInfoLst = new ObservableCollection<YSP_StoreInfoList>();
        void obb_getStoreInfoCompleted(object sender, LocalWalletServices.getStoreInfoCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                listBox1.Items.Clear();
 
                for (int i = 0; i < e.Result.storeInfoList.storeInfoCount; i++)
                {
                    _StoInfoLst.Add(new YSP_StoreInfoList { Address1 = e.Result.storeInfoList.storeInfo[i].address1, StoreID = e.Result.storeInfoList.storeInfo[i].storeID });
                }
                listBox1.ItemsSource = _StoInfoLst;
                //e.Result.storeInfoList.storeInfo[].
                // daata insert
            }
            //throw new NotImplementedException();
        }
 

 
and Class i used
 
internal class YSP_StoreInfoList
    {
        public string Address1 { get; set; }
 
        public string StoreID { get; set; }
 
    }
Posted 3-Jun-12 23:05pm
Comments
Jeff Blankenburg at 20-Feb-13 8:29am
   
Looking at your code, I don't see anything obvious that would prevent it from working. When you say "didn't get success", what do you mean?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 494
1 CPallini 325
2 OriginalGriff 225
3 George Jonsson 130
4 ChauhanAjay 104
0 OriginalGriff 6,464
1 Sergey Alexandrovich Kryukov 5,915
2 CPallini 5,175
3 George Jonsson 3,559
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 4 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100