Answered by:
how to generate text block dynamically

Question
-
hi
em beginner in windows phone i need help in my pplication i have creted wcf service my application retrieve data from service e.g e.g i got 4 record (according to my query) i want to create 4 textblock dynamically generate during run time ( textblock should generate according to record e.g some time 2 records,3 records e.t.c) according to my records or data i wana generate textblock dynamically and whenever i click on texkblock it show me detail e.t.c
Thursday, January 10, 2013 7:08 PM
Answers
-
Usman, here are few considerations for you before answer to this particular post of yours,
1- One question at a time in each thread please? If I would be you, I'll either mark answer by Richard Woo as resolved or discuss issues I have with that but won't ask for COMPLETE SOLUTION to just replicate in same thread.
2- Don't ask for code that you don't understand a bit and just want to copy/paste that.
3- Share part of your code that you are not able to sort out. This will help you more.
Having said above, here's what you should do next
1- Learn how to consume a WCF service in a WP project. Simply right click on References node in solution explorer and select "Add Service Reference". Provide WSDL and add the service. Rest Visual Studio will create relative classes for you to consume. If you haven't done that, this tutorial will help,
http://www.tapanila.net/consuming-wcf-service-with-windows-phone/
2- Given the response retrieved use the answer from Richard and use search engine and this forum for particular answers.
3- Once you understand above, ask yourself if you really need to generate dynamic text blocks? I don't think so. I think a listbox is what you need and that will also help you understand DataBinding in .NET. Here's a Url I suggest considering in reference to WCF and almost cover entire scope of your mentioned FYP to be consulted,
http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_windowsphone7andthecloud_topic2.aspx
- Edited by Usman Ur Rehman Ahmed Sunday, January 20, 2013 12:42 PM refined
- Marked as answer by usman shah Monday, January 21, 2013 6:35 PM
Sunday, January 20, 2013 12:29 PM
All replies
-
plz help me with code em beginner here dont have good concepts
thanks
Thursday, January 10, 2013 7:10 PM -
please help meSaturday, January 19, 2013 8:38 AM
-
hi
em beginner in windows phone i need help in my pplication i have creted wcf service my application retrieve data from service e.g e.g i got 4 record (according to my query) i want to create 4 textblock dynamically generate during run time ( textblock should generate according to record e.g some time 2 records,3 records e.t.c) according to my records or data i wana generate textblock dynamically and whenever i click on texkblock it show me detail e.t.c
for(int i=0;i<4;++i) { TextBlock tb = new TextBlock(); tb.Text = i.ToString(); tb.SetProperty(Grid.Row, (double)i); myGrid.Controls.Add(tb); }
this assumes that you have a grid named myGrid on your page.Joel Ivory Johnson | http://www.j2i.net | Windows Phone Developer MVPIt takes all the running you can do to stay in one place.If you want to get somewhere else,you must try to run at least twice as fast as that.- Proposed as answer by WmDev Monday, January 21, 2013 6:01 AM
Saturday, January 19, 2013 1:50 PM -
Since you don't know in advance how many TextBlocks to add, it would be simpler to use it with a StackPanel in your page:
TextBlock tb = new TextBlock();
tb.Text = "some text";
mystackpanel.Children.Add(tb);
TextBlock tb2 = new TextBlock();
tb2.Text = "more text";
mystackpanel.Children.Add(tb2);Based on your description, it would be best if you learn to how use databinding, but that is a much bigger topic.
Richard WooSaturday, January 19, 2013 10:19 PM -
hi em beginner in windows phone i have to create my fyp soon i have created wcf service and in mobile i have datetime pikker whenever i send date to service it return me record and shown on messagebox i want to create dynamically textblock it sees from service how much record are coming and then created it accordingly and when ever i clicked on any of textblock that are dynamically generated i can see detail of record how can i do this plz help me with code should i make user control class but how???? plz plz help me urgently as soon as possible
Sunday, January 20, 2013 5:49 AM -
Usman, here are few considerations for you before answer to this particular post of yours,
1- One question at a time in each thread please? If I would be you, I'll either mark answer by Richard Woo as resolved or discuss issues I have with that but won't ask for COMPLETE SOLUTION to just replicate in same thread.
2- Don't ask for code that you don't understand a bit and just want to copy/paste that.
3- Share part of your code that you are not able to sort out. This will help you more.
Having said above, here's what you should do next
1- Learn how to consume a WCF service in a WP project. Simply right click on References node in solution explorer and select "Add Service Reference". Provide WSDL and add the service. Rest Visual Studio will create relative classes for you to consume. If you haven't done that, this tutorial will help,
http://www.tapanila.net/consuming-wcf-service-with-windows-phone/
2- Given the response retrieved use the answer from Richard and use search engine and this forum for particular answers.
3- Once you understand above, ask yourself if you really need to generate dynamic text blocks? I don't think so. I think a listbox is what you need and that will also help you understand DataBinding in .NET. Here's a Url I suggest considering in reference to WCF and almost cover entire scope of your mentioned FYP to be consulted,
http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_windowsphone7andthecloud_topic2.aspx
- Edited by Usman Ur Rehman Ahmed Sunday, January 20, 2013 12:42 PM refined
- Marked as answer by usman shah Monday, January 21, 2013 6:35 PM
Sunday, January 20, 2013 12:29 PM -
thank you very much brother.. your reply has solved my issue almost :)Monday, January 21, 2013 6:36 PM