0

저는 C#과 Html을 사용하여 Windows 8 앱을 만드는 데 어려움을 겪고 있습니다. 하지만 특정 기능 때문에 HTML을 사용하기로 결정했습니다. 하지만 Listview Item/Element/Child가 선택되어 있다면 문제가 발생했습니다.Windows 8 Javascript : Listview invoke trouble

<div id="shapeListItem" data-win-control="WinJS.Binding.Template" style="display: none;"> 
    <div style="width: 100px; height: 100px;"> 
     <img src="#" style="width: 100px; height: 100px;" data-win-bind="src: picture" /> 
    </div> 
</div> 

<div id="shapes" data-win-control="WinJS.UI.ListView" data-win-options="{itemDataSource : shapeTemplate.itemList.dataSource, 
     itemTemplate: select('#shapeListItem'), 
     tapBehavior: 'toggleSelect', 
     selectionMode: 'single'}"> 
</div> 

그리고 내 자바 스크립트 : 이것은 내 HTML에서 무엇을 가지고

WinJS.Utilities.ready(function() { init(); }); 

function init() { 
    var shapes = document.getElementById("shapes").winControl; 
    //shapes.selected ??? 
} 

내가 무엇을 시도했다 모든 기억하지 않습니다하지만 난 그게 작동도 없었어. 나는 단지 어떤 아이템이 선택되고 그것으로부터 이미지 uri를 얻고 싶다. 또는 다른 방법으로 잘 작동하는 것으로 보이는 데이터 바인딩에 다른 제목이나 다른 것을 추가 할 수 있습니다. 다른 제안이나 방법이 있으면 감사하게 생각합니다. 또는 더 많은 코드를 게시해야한다면 그렇게 할 것입니다.

다시 한 번 감사드립니다, 스티븐

편집 :하지만 그 오류를 내놓았다 : 나는 또한 " '핸들러'를 onitemInvoke"을 추가하려고했습니다 오.

답변

0

문서 : http://msdn.microsoft.com/en-us/library/windows/apps/br211852.aspx

보십시오 : 당신을 위해이 트릭을 할 것입니다

function init() { 
    var shapes = document.getElementById("shapes").winControl; 
    // gets an array of the indices: 
    var selectedIndices = shapes.selection.getIndices(); 
} 

:

function init() { 
    var shapes = document.getElementById("shapes").winControl; 
    debugger; 
    // gets an array of the indices: 
    var selectedIndices = shapes.selection.getIndices(); 
} 

그런 식 창에 "모양"을 추가 - 당신이 될 것입니다 API를 볼 수 있습니다.