Reputation: 448
I have a data coming from asp.net web service. The field contains News_title
, News_description
, Date_start
, image_path
. Now I want to show data in list view. Suppose if the data in the web service is increased my list should also show that data dynamically in the phone application.
My xaml.cs code is
public News()
{
InitializeComponent();
KejriwalService.aapSoapClient client = new KejriwalService.aapSoapClient();
client.getarvindNewsCompleted += new EventHandler<KejriwalService.getarvindNewsCompletedEventArgs>(client_getarvindNewsCompleted);
client.getarvindNewsAsync();
}
void client_getarvindNewsCompleted(object sender, KejriwalService.getarvindNewsCompletedEventArgs e)
{
// throw new NotImplementedException();
}
Can anyone tell me how to add this list view and show the result in client_getarvindNewsCompleted method. I am able to show the result in text block by doing the following
void client_getarvindNewsCompleted(object sender, KejriwalService.getarvindNewsCompletedEventArgs e)
{
var data = e.Result;
XElement xml = XElement.Parse(data);
textblock1.Text = xml.Elements("UserDetails").Elements("News_Title").First().Value;
var data1 = e.Result;
XElement xml1 = XElement.Parse(data1);
textblock2.Text = xml1.Elements("UserDetails").Elements("News_description").First().Value;
}
Similarly for the other field. I also have an image in this webservice
coming from a backoffice
. How can i show these in 1 view such that when 1 box is clicked it shows the complete result
This is my xaml.cs file code
void client_getarvindNewsCompleted(object sender, KejriwalService.getarvindNewsCompletedEventArgs e)
{
var data = e.Result;
XElement xml = XElement.Parse(data);
textBox1.DataContext = xml.Elements("UserDetails").Elements("News_Title").First().Value;
var data1 = e.Result;
XElement xml1 = XElement.Parse(data1);
textBox1.DataContext = xml1.Elements("UserDetails").Elements("News_Description").First().Value;
var data2 = e.Result;
XElement xml2 = XElement.Parse(data2);
textBox1.DataContext = xml2.Elements("UserDetails").Elements("Date_Start").First().Value;
//textBox1.DataContext = e.Result;
// throw new NotImplementedException();
}
And the code in xaml for binding:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBox VerticalAlignment="Top" IsReadOnly="True" Margin="5,5,5,0"
TextWrapping="Wrap" Height="336" Width="400"
Text="{Binding}" x:Name="textBox1" />
</Grid>
I am not getting all the result. I am only getting the result for date_start. Please help me to get all the result. I want to only show a small part of the result in a box and when it is clicked the complete result should come. Please help
Upvotes: 2
Views: 471
Reputation: 2848
Data Binding would be a very stable solution. Check the following articles on MVVM.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/cc278072(v=vs.105).aspx
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207023(v=vs.105).aspx
Upvotes: 1