Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If data is coming correctly in e.Result as the way you want to display it in the listbox.you may look into the following.Here I am getting data from the wcf service.</p> <p>lets say in your mainPage.xaml.cs we can add the following code</p> <p>as here I am using wcf service we need to write following</p> <pre><code> // Constructor public MainPage() { InitializeComponent(); UserServiceReference.ServiceClient client = new ServiceClient(); //Event handler after webservice completes operation. client.UserDetailsCompleted += new EventHandler&lt;UserDetailsCompletedEventArgs&gt; (serviceClient_UserDetailsCompleted); client.UserDetailsAsync(); } } //Completed event of the UserDetails public void serviceClient_UserDetailsCompleted(Object sender,UserDetailsCompletedEventArgs e ) { try { var lsdUser = e.Result.ToList(); foreach (var userData in lsdUser) { User userObj = new User(); userObj.UserName =userData[0].ToString(); userObj. userCity = userData[1].ToString(); userObj. userState=userData[2].ToString(); userObj. userGender=userData[3].ToString(); userObj. userAge=userData[4].ToString(); userObj. userDescription=userData[5].ToString(); userList.Add(userObj); } //Binding Data to the userListBox userListBox.ItemsSource = userList; } catch (Exception ex) { string message = ex.ToString(); } } </code></pre> <p>And in the Xaml we can bind data using itemTemplate and dataTemplate</p> <pre><code> &lt;ListBox Height="279" Name="userListBox" Background="White" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" Margin="0,5,0,0" &gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;StackPanel Orientation="Vertical"&gt;&lt;/StackPanel&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal" x:Name="user" Width="600"&gt; &lt;TextBlock x:Name="txtUserName" Text="{Binding UserName}" Foreground="Black" Width="100" Height="65" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0,0,0"&gt; &lt;/TextBlock&gt; &lt;TextBlock x:Name="txtUserCity" Text="{Binding UserCity}" Foreground="Black" Width="100" Height="65" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0,0,0"&gt; &lt;/TextBlock&gt; &lt;TextBlock x:Name="txtUserState" Text="{Binding UserState}" Foreground="Black" Width="100" Height="65" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0,0,0"&gt; &lt;/TextBlock&gt; &lt;TextBlock x:Name="txtUserGender" Text="{Binding UserGender}" Foreground="Black" Width="100" Height="65" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0,0,0"&gt; &lt;/TextBlock&gt; &lt;TextBlock x:Name="txtUserAge" Text="{Binding UserAge}" Foreground="Black" Width="100" Height="65" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0,0,0"&gt; &lt;/TextBlock&gt; &lt;TextBlock x:Name="txtUserDescription" Text="{Binding UserDescription}" Foreground="Black" Width="100" Height="65" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0,0,0"&gt; &lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>Hope it will help you in some extent,the only difference is here that I am getting data from the wcf service.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload