Click here to Skip to main content
15,891,372 members

ListBox, Binding error in Windows phone 7

shiva.ankit asked:

Open original thread
XML
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; }

    }
Tags: ListBox

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900