26593

Loading Contents into TextBox in WP8

Question:

I need to update the data on my server.

<ul><li>I need to GET the data</li> <li>And need to store it in a TextBox</li> <li>Then I need to perform my Update operation.</li> </ul>

I'm able to GET the data from server but unable to display it in the text box

<strong>MY in XAML code:</strong>

<Grid x:Name="ContentPanel" Margin="12,157,12,4" Grid.RowSpan="2"> <TextBlock HorizontalAlignment="Left" Height="30" Margin="20,67,0,0" TextWrapping="Wrap" Text="Name" VerticalAlignment="Top" Width="65"/> <TextBox x:Name="txt_name" HorizontalAlignment="Left" Height="73" Margin="121,42,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="PersonalFullName"/> </Grid>

<strong>My code to retrieve data from server on page load:</strong>

private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { String OrganizationResult; if (NavigationContext.QueryString.ContainsKey("selectedItem")) { OrganizationResult = NavigationContext.QueryString["selectedItem"]; string[] content = OrganizationResult.Split(','); string value = content[0]; String id = value.Replace("{ id = ", ""); Organization[] org; org = await client.searchOrganizationdetails(id); if (org != null) { var query = from c in org select new { // Need to display the contents in textbox // Eg:txt_name.Text=c.name }; } } }

<strong>My sample JSON data:</strong>

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/yrYHs.png" data-original="https://i.stack.imgur.com/yrYHs.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Answer1:

If you need to bind to a list

Assuming you collection is of the type

public class Organization { public string Name { get; set; } public string Address { get; set; } }

Your xaml should look like

<ListBox x:Name="lstOrganisations"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" /> <TextBox Text="{Binding Address}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>

Bind with

lstOrganisations.ItemSource = org;

Answer2:

Does it need to be <strong>inside</strong> the LINQ query?I don't think you can do that...

Recommend

  • Cannot await 'void' error in windows phone
  • Fade opacity when scrolling
  • Null pointer exception on null object reference
  • Converting Data to string gets nil value
  • EditText on demand widget
  • Windows Phone 7 - Playing streaming video
  • How to find point on Path from the closest point?
  • How to set textwrapping in Button
  • Delete an item in a listbox with a button, in wpf MVVM
  • Scroller-like animation on a Label in WPF
  • A ListBoxItem that fills its parent
  • How to align text in a WPF menu item?
  • Flyout changes Page's theme
  • Can I use PropertyChanged and LostFocus together?
  • UWP XAML ImageBrush.imageSource from networkshare
  • Using ListPicker and DataBinding
  • Bind Xaml bitmap image
  • Binding Selected RowCount to TextBlock not Firing OnPropertyChanged after DataGrid Scroll
  • Set step size polar plot matplotlib python
  • Caliburn Micro, How to use ContentControl (or display 'sub' ViewModel) using ViewModel Fir
  • How to add a focus style to an editable ComboBox in WPF
  • how to display data from 1st point on words on y axis for line chart in d3.js
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • Disable Enter in editText android
  • Change multiple background-images with jQuery
  • Algorithm for a smudge tool?
  • Email format validation in mvc3 view
  • Can Jackson SerializationFeature be overridden per field or class?
  • javascript inside java/jsp code
  • How to check if every primary key value is being referenced as foreign key in another table
  • How to show dropdown in excel using jrxml (jasper api)?
  • Web-crawler for facebook in python
  • Android Studio and gradle
  • trying to dynamically update Highchart column chart but series undefined
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • python regex in pyparsing
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • python draw pie shapes with colour filled
  • java string with new operator and a literal