Answered by:
How do I data bind string array item in metro ListView template?

Question
-
I have
var myCars=["Honda","Volvo","BMW"];
then my template I have,
<span> data-win-bind="innerText: ??"></span>
what to put after innerText to show mycars?
Thanks.
Mango Boy.
- Edited by Ashraf TM Wednesday, August 8, 2012 10:31 PM
Wednesday, August 8, 2012 6:52 PM
Answers
-
Hi
You can't do that binding .
You should use WinJS.Binding.define to supports observability with the specified set of properties. Or use WinJS.Binding.List
<script type="text/javascript"> var Car= WinJS.Binding.define({ name: "", }); //You can use a method to loop your array's value to the myCars var myCars= [ new Car({ name: "Honda"}), new Car({name:"Volvo"}) ]; </script>
Please check this two Links:
http://msdn.microsoft.com/en-us/library/windows/apps/hh700356.aspx
http://code.msdn.microsoft.com/windowsapps/ListView-item-templates-7d74826f- Marked as answer by Ashraf TM Monday, August 13, 2012 4:56 PM
Thursday, August 9, 2012 2:16 AM
All replies
-
Hi
You can't do that binding .
You should use WinJS.Binding.define to supports observability with the specified set of properties. Or use WinJS.Binding.List
<script type="text/javascript"> var Car= WinJS.Binding.define({ name: "", }); //You can use a method to loop your array's value to the myCars var myCars= [ new Car({ name: "Honda"}), new Car({name:"Volvo"}) ]; </script>
Please check this two Links:
http://msdn.microsoft.com/en-us/library/windows/apps/hh700356.aspx
http://code.msdn.microsoft.com/windowsapps/ListView-item-templates-7d74826f- Marked as answer by Ashraf TM Monday, August 13, 2012 4:56 PM
Thursday, August 9, 2012 2:16 AM -
Hi Dino thanks for the answer. what I understand from your answer is; in metro we cannot bind data to html control without a property name. right? Framework like knockout supports these functionality through $data keyword.
http://stackoverflow.com/questions/7248719/bind-to-simple-array-of-strings
Mango Boy.
Thursday, August 9, 2012 6:35 PM -
HI
Oh no, I mean WinJS.Binding.Template not support.
Metro support most of third part javascript framework .
You can try that in metro style app.
Dino
Friday, August 10, 2012 3:10 AM