I am working in windows phone application where i have one ListBox control. And one button as inner control.
So in list 20 buttons after binding data. Now I want to change the data of button once it clicked.
This is my sample code. this is my first app windows phone.
<ListBox Grid.Row="1" HorizontalAlignment="Left" Margin="10,10,0,0" Name="lstInstagramTags" VerticalAlignment="Top" Width="444" Height="562" SelectionChanged="lstInstagramTags_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="100" Margin="-10,-10,-10,-10">
<Button Click="Button_Click" Content="NeedToChangeThisValue" Width="150" FontSize="13" Height="60" Margin="-560,35,5,5" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
private void Button_Click(object sender, RoutedEventArgs e)
{
HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(myUri);
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), myRequest);
}
void GetRequestStreamCallback(IAsyncResult callbackResult)
{
HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
// End the stream request operation
Stream postStream = myRequest.EndGetRequestStream(callbackResult);
string PostData = "action=follow&access_token=966258514.201df4f.4b1c5015a7784a63aac00b9a902c4176";
// Create the post data
string postData = PostData;
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Add the post data to the web request
postStream.Write(byteArray, 0, byteArray.Length);
postStream.Close();
// Start the web request
myRequest.BeginGetResponse(new AsyncCallback(GetResponsetStreamCallback), myRequest);
}
void GetResponsetStreamCallback(IAsyncResult callbackResult)
{
HttpWebRequest request = (HttpWebRequest)callbackResult.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(callbackResult);
using (StreamReader httpWebStreamReader = new StreamReader(response.GetResponseStream()))
{
**string result** = httpWebStreamReader.ReadToEnd();
}
}
I want to change the button data based on the result (Marked Bold). I am not getting way to update any control on the basis of this result.
Please suggest me any good way to get this.
Thanks