Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Nov 2013

    Question WP7 - Need help with Custom ListBox databinding

    Hi guys!, New member here
    So i was just wondering if any of you can help me with something. So basically I'm making this app and it has a listbox. I've edited the Listbox Item template so it looks something like this:

    Now the XAML for this is:
    <ControlTemplate TargetType="ListBoxItem"> <StackPanel x:Name="ItmParent" Height="87" Width="470" HorizontalAlignment="Left" toolkit:TiltEffect.IsTiltEnabled="True" VerticalAlignment="Top" > <toolkit:ContextMenuService.ContextMenu> <toolkit:ContextMenu IsZoomEnabled="True" x:Name="menu"> <toolkit:MenuItem Header="Edit Account" Click="Edit_Click" FontFamily="Segoe WP" Background="Transparent" BorderBrush="Black"/> <toolkit:MenuItem Header="Delete Account" Click="Delete_Click" FontFamily="Segoe WP"/>
    </toolkit:ContextMenu> </toolkit:ContextMenuService.ContextMenu> <TextBlock x:Name="Name" Height="51" TextWrapping="Wrap" Text="{TemplateBinding Content}" FontFamily="Segoe WP SemiLight" FontSize="37.333" Foreground="White" HorizontalAlignment="Left"/> <TextBlock x:Name="Line" Height="36" TextWrapping="Wrap" Text="{TemplateBinding Content}" FontSize="21.333" FontFamily="Segoe WP" Margin="1,0,-1,0" Style="{StaticResource TextBlockStyle1}"> <TextBlock.Foreground> <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/> </TextBlock.Foreground> </TextBlock> </StackPanel> </ControlTemplate>
    So That's that! Now i use this to load some files from this folder in the isolated storage and the code i use to do this is:
    Dim Storage As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
        Dim directory As String = "./SafeLockPLUS/SavedAccounts/*.*"
        Dim filenames As String() = Storage.GetFileNames(directory)
        SavedAccountslst.ItemsSource = filenames
    So when i run it i get something like this:

    I know i get the same thing on both the edited items because i set both of them to the same bind(Text="{TemplateBinding Content}"). Now the way i want it is to be the First item being the filename and the second item being when the file was created? Can someone please help me with this problem. I've been trying to look up examples and all sorts but it just shows me the already added items in a listbox not something like this.
    Some examples are:


  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2013
    Dublin, Ireland

    Re: WP7 - Need help with Custom ListBox databinding

    I'm not sure what example you were following, but it's wrong. I would suggest following the approach from the official MSDN documentation...


    It starts of quite basic but you'll eventually see how to use a ListBox with it's ItemTemplate, then bind to an ObservableCollection which contains a list of the data you want to display.

    Also, you might want to think about switching over to C# as most code samples and 3rd party libraries are written using it, not VB.

Similar Threads

  1. ListBox DataBinding issue in WP 7.5
    By paraswadehra in forum Windows Phone General
    Replies: 5
    Last Post: 2013-02-14, 19:09
  2. Xml DataBinding sis file
    By george0095 in forum Series 40 & S60 Platform Feedback Archive
    Replies: 4
    Last Post: 2008-10-15, 15:10
  3. Custom Listbox
    By aoikonom in forum Symbian User Interface
    Replies: 0
    Last Post: 2008-03-04, 10:53
  4. Using skins! Custom Listbox / Custom ListItemDrawer
    By akrapacs in forum Symbian User Interface
    Replies: 1
    Last Post: 2007-01-22, 10:05
  5. big custom listbox
    By ajaykapur in forum Symbian User Interface
    Replies: 4
    Last Post: 2006-07-12, 10:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts