使用SplitView模板将Tiles固定到“开始”屏幕 [英] Pinning Tiles to the Start Screen using SplitView Template

查看:72
本文介绍了使用SplitView模板将Tiles固定到“开始”屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在为固定磁贴拉出正确的章节和书籍信息时遇到问题。它始终是第一本书的第一章。此代码适用于gridView模板,但不适用于splitView。我也有同样的问题,共享联系人电子邮件
应用程序。请协助!

I am having problems pulling the correct chapter and book info for the pinned tile. It always pins the first chapter of the first book. This code works for the gridView template but not the splitView. I have the same problem with sharing contact to email applications as well. Please assist!

(function(){

   " use strict" ;;



    var appViewState = Windows.UI.ViewManagement.ApplicationViewState;

    var binding = WinJS.Binding;

    var utils = WinJS.Utilities;

    var app = WinJS.Application;

    VAR活化= Windows.ApplicationModel.Activation;

    VAR NAV = WinJS.Navigation;

     var item;

    var ui = WinJS.UI;

    var start = Windows.UI.StartScreen ;

    VAR DTM = Windows.ApplicationModel.DataTransfer.DataTransferManager;



    WinJS。 UI.Pages.define(QUOT; /pages/splitPage/splitPage.html" ;, {

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; ///<字段类型= QUOT ; WinJS.Binding.List" />

        _items:null,

        _group:null,

        _itemSelectionIndex:-1,
$


        currentIndex:1,
$


        //每当用户导航到此页面时,都会调用此函数。它是
        //使用应用程序的数据填充页面元素。



        ready:function(element,options){

            var listView = element.querySelector(" .itemlist")。winControl;



          &NBSP;&NBSP; //存储有关该页面的信息以及此页面的选择<
            // display。

            this._group =(options&& options.groupKey)? Data.resolveGroupReference(options.groupKey):Data.groups.getAt(0);

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; this._items = Data.getItemsFromGroup(this._group);

            this._itemSelectionIndex =(选项中的选项&&" selectedIndex")? options.selectedIndex:-1;



            //设置ListView。

            listView.itemDataSource = this._items.dataSource;

            listView.itemTemplate = element.querySelector(QUOT; .itemtemplate");

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; listView.onselectionchanged = this._selectionChanged.bind(本);

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; listView.layout =新ui.ListLayout();



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; item = options&& options.item? Data.resolveItemReference(options.item):Data.items.getAt(0);

            element.querySelector(QUOT; .item-DESCRIPT")的innerHTML = this._group.description;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; element.querySelector(QUOT;文章.article含量")。innerHTML的= item.content;



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP; element.querySelector(QUOT;报头[角色=横幅] .pagetitle")的textContent = this._group.title;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP; element.querySelector(QUOT; .title伪")。的textContent = this._group.title;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; element.querySelector(QUOT;。短路")。的textContent = this._group.short;



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; document.getElementById(" pinTile")。addEventListener(" click",pinCustomSecondaryTile,false);
$
           &NBSP;的document.getElementById(QUOT; shareText")的addEventListener(QUOT;按一下[;, shareButtonHandler,假);



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; 。dtm.getForCurrentView()的addEventListener(QUOT; datarequested" ;, this.onDataRequested);



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; this._updateVisibility();

            if(this._isSingleColumn()){
$
               如果(this._itemSelectionIndex> = 0){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; //对于单柱详细视图,加载文章

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP; binding.processAll(element.querySelector(QUOT; .articlesection"),this._items.getAt(this._itemSelectionIndex));

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; }
            }其他{

               如果(nav.canGoBack&安培;&安培; nav.history.backStack [nav.history.backStack.length - 1] .location ===" /pages/splitPage/splitPage.html"){

                    //清理返回堆栈处理用户捕捉,导航

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP; //远,上松开,然后返回此页

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP; nav.history.backStack.pop();

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; }
                //如果这个页面有一个selectionIndex,作出这样的选择

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; //出现在ListView中。

                listView.selection.set(Math.max(this._itemSelectionIndex,0));

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; }
        },b
$ b $ n        //此功能更新页面布局以响应viewState更改。

        updateLayout:function(element,viewState,lastViewState){

            ///< param name =" element"一个DOMElement = QUOT;真" />
$


            VAR的ListView = element.querySelector(QUOT; .itemlist")WINCONTROL;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; var firstVisible = listView.indexOfFirstVisible;

            this._updateVisibility();
$


            var handler = function(e){

                listView.removeEventListener(QUOT; contentanimating" ;,处理程序,FALSE);

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP; e.preventDefault();

            }


            if(this._isSingleColumn()){
$
                listView.selection.clear();

               如果(this._itemSelectionIndex> = 0){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; //如果应用已合并到单列详情视图中,则为
               ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; //添加单柱列表视图返回堆栈

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP; nav.history.current.state = {

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; groupKey:this._group.key,

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;的selectedIndex:this._itemSelectionIndex

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; };

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; nav.history.backStack.push({

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;位置:" /pages/splitPage/splitPage.html" ;,

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;                state:{groupKey:this._group.key}

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;});

&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; element.querySelector(QUOT; .articlesection")聚焦();

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP; }其他{

                    listView.addEventListener(QUOT; contentanimating" ;,处理程序,FALSE);

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;如果(firstVisible> = 0&安培;&安培; listView.itemDataSource.list.length大于0){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; listView.indexOfFirstVisible = firstVisible;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP; }

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; listView.forceLayout();

                }
            }其他{

                //如果应用已取消绑定到双列视图中,请删除所有
                    nav.history.backStack.pop();

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; }
               如果(视图状态== lastViewState!){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP; listView.addEventListener(QUOT; contentanimating" ;,处理程序,FALSE);

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;如果(firstVisible> = 0&安培;&安培; listView.itemDataSource.list.length大于0){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; listView.indexOfFirstVisible = firstVisible;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP; }

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; listView.forceLayout();

                }


                listView.selection.set(this._itemSelectionIndex> = 0 this._itemSelectionIndex:Math.max(firstVisible,0));

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP; }
        },b
$ b $ n        //此功能检查是否应显示列表和详细信息列

        //在不同的页面上而不是并排。

        _isSingleColumn:function(){

            var viewState = Windows.UI.ViewManagement.ApplicationView.value;

        },b
$ b $ n        _selectionChanged:function(args){

            VAR的ListView = document.body.querySelector(QUOT; .itemlist")WINCONTROL;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; var details;

            //默认情况下,选择限制为单个项目。

            。listView.selection.getItems()来完成(功能updateDetails(项目){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;    if(items.length> 0){

               &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; this._itemSelectionIndex =项[0]的.index;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;若(this._isSingleColumn()){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; //如果折断或画像,浏览到包含
$ b了新的一页$ b&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; //所选项目的详细信息。



           &n BSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;细节= document.querySelector(QUOT; .articlesection");

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; binding.processAll(details,items [0] .data);

               &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; details.scrollTop = 0;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP; }其他{

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; //如果全屏或填充,用新数据更新的细节列

(function () {
    "use strict";

    var appViewState = Windows.UI.ViewManagement.ApplicationViewState;
    var binding = WinJS.Binding;
    var utils = WinJS.Utilities;
    var app = WinJS.Application;
    var activation = Windows.ApplicationModel.Activation;
    var nav = WinJS.Navigation;
    var item;
    var ui = WinJS.UI;
    var start = Windows.UI.StartScreen;
    var dtm = Windows.ApplicationModel.DataTransfer.DataTransferManager;

    WinJS.UI.Pages.define("/pages/splitPage/splitPage.html", {
        /// <field type="WinJS.Binding.List" />
        _items: null,
        _group: null,
        _itemSelectionIndex: -1,

        currentIndex: 1,

        // This function is called whenever a user navigates to this page. It
        // populates the page elements with the app's data.

        ready: function (element, options) {
            var listView = element.querySelector(".itemlist").winControl;

            // Store information about the group and selection that this page will
            // display.
            this._group = (options && options.groupKey) ? Data.resolveGroupReference(options.groupKey) : Data.groups.getAt(0);
            this._items = Data.getItemsFromGroup(this._group);
            this._itemSelectionIndex = (options && "selectedIndex" in options) ? options.selectedIndex : -1;

            // Set up the ListView.
            listView.itemDataSource = this._items.dataSource;
            listView.itemTemplate = element.querySelector(".itemtemplate");
            listView.onselectionchanged = this._selectionChanged.bind(this);
            listView.layout = new ui.ListLayout();

            item = options && options.item ? Data.resolveItemReference(options.item) : Data.items.getAt(0);
            element.querySelector(".item-descript").innerHTML = this._group.description;
            element.querySelector("article .article-content").innerHTML = item.content;

            element.querySelector("header[role=banner] .pagetitle").textContent = this._group.title;
            element.querySelector(".title").textContent = this._group.title;
            element.querySelector(".short").textContent = this._group.short;

            document.getElementById("pinTile").addEventListener("click", pinCustomSecondaryTile, false);
            document.getElementById("shareText").addEventListener("click", shareButtonHandler, false);

            dtm.getForCurrentView().addEventListener("datarequested", this.onDataRequested);

            this._updateVisibility();
            if (this._isSingleColumn()) {
                if (this._itemSelectionIndex >= 0) {
                    // For single-column detail view, load the article.
                    binding.processAll(element.querySelector(".articlesection"), this._items.getAt(this._itemSelectionIndex));
                }
            } else {
                if (nav.canGoBack && nav.history.backStack[nav.history.backStack.length - 1].location === "/pages/splitPage/splitPage.html") {
                    // Clean up the backstack to handle a user snapping, navigating
                    // away, unsnapping, and then returning to this page.
                    nav.history.backStack.pop();
                }
                // If this page has a selectionIndex, make that selection
                // appear in the ListView.
                listView.selection.set(Math.max(this._itemSelectionIndex, 0));
            }
        },

        // This function updates the page layout in response to viewState changes.
        updateLayout: function (element, viewState, lastViewState) {
            /// <param name="element" domElement="true" />

            var listView = element.querySelector(".itemlist").winControl;
            var firstVisible = listView.indexOfFirstVisible;
            this._updateVisibility();

            var handler = function (e) {
                listView.removeEventListener("contentanimating", handler, false);
                e.preventDefault();
            }

            if (this._isSingleColumn()) {
                listView.selection.clear();
                if (this._itemSelectionIndex >= 0) {
                    // If the app has snapped into a single-column detail view,
                    // add the single-column list view to the backstack.
                    nav.history.current.state = {
                        groupKey: this._group.key,
                        selectedIndex: this._itemSelectionIndex
                    };
                    nav.history.backStack.push({
                        location: "/pages/splitPage/splitPage.html",
                        state: { groupKey: this._group.key }
                    });
                    element.querySelector(".articlesection").focus();
                } else {
                    listView.addEventListener("contentanimating", handler, false);
                    if (firstVisible >= 0 && listView.itemDataSource.list.length > 0) {
                        listView.indexOfFirstVisible = firstVisible;
                    }
                    listView.forceLayout();
                }
            } else {
                // If the app has unsnapped into the two-column view, remove any
                if (nav.canGoBack && nav.history.backStack[nav.history.backStack.length - 1].location === "/pages/splitPage/splitPage.html") {
                    nav.history.backStack.pop();
                }
                if (viewState !== lastViewState) {
                    listView.addEventListener("contentanimating", handler, false);
                    if (firstVisible >= 0 && listView.itemDataSource.list.length > 0) {
                        listView.indexOfFirstVisible = firstVisible;
                    }
                    listView.forceLayout();
                }

                listView.selection.set(this._itemSelectionIndex >= 0 ? this._itemSelectionIndex : Math.max(firstVisible, 0));
            }
        },

        // This function checks if the list and details columns should be displayed
        // on separate pages instead of side-by-side.
        _isSingleColumn: function () {
            var viewState = Windows.UI.ViewManagement.ApplicationView.value;
        },

        _selectionChanged: function (args) {
            var listView = document.body.querySelector(".itemlist").winControl;
            var details;
            // By default, the selection is restriced to a single item.
            listView.selection.getItems().done(function updateDetails(items) {
                if (items.length > 0) {
                    this._itemSelectionIndex = items[0].index;
                    if (this._isSingleColumn()) {
                        // If snapped or portrait, navigate to a new page containing the
                        // selected item's details.

                        details = document.querySelector(".articlesection");
                        binding.processAll(details, items[0].data);
                        details.scrollTop = 0;
                    } else {
                        // If fullscreen or filled, update the details column with new data.

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;细节= document.querySelector(QUOT; .articlesection");

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; binding.processAll(details,items [0] .data);

               &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; details.scrollTop = 0;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP; }
                }
            } .bind(this));
$
        },b
$ b $ n        //此功能根据当前的结果切换两列的可见性。&$ n        //查看状态和项目选择。

        _updateVisibility:function(){

            var oldPrimary = document.querySelector(" .primarycolumn");

            if(oldPrimary){

                utils.removeClass(oldPrimary," primarycolumn");

            }
            if(this._isSingleColumn()){
$
               如果(this._itemSelectionIndex> = 0){

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; utils.addClass(document.querySelector(QUOT; .articlesection")," primarycolumn");

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; document.querySelector(QUOT; .articlesection")聚焦();

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP; }其他{

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; utils.addClass(document.querySelector(QUOT; .itemlistsection")," primarycolumn");

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; document.querySelector(QUOT; .itemlist")聚焦();

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP; }
            }其他{

                document.querySelector(" .itemlist")。focus();

            }
        },b
$ b $ n        onDataRequested:function(e){

            var request = e.request;

            request.data.properties.title = item.group.title +" (从Windows 8发送)" ;;

            request.data.properties.description =" Chapter" + item.title;
$


            var chapText = item.content;

            // var bookDescript = item.group.description;

            var chapName =" Chapter" + item.title;

            var space ='< br>< br>';

           

            var htmlFormat = Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.createHtmlFormat(chapName + space + chapText);

            request.data.setHtmlFormat(htmlFormat);

        }
    });
$


    function shareButtonHandler(){

        Windows.ApplicationModel.DataTransfer.DataTransferManager.showShareUI();

    }


     function pinCustomSecondaryTile(){

        var tileId =" customTile" + new Date()。getTime();

        var uriLogo = new Windows.Foundation.Uri(item.backgroundImage);

        var uriSmallLogo = new Windows.Foundation.Uri(" ms-appx:///images/pinned.jpg");

     &NBSP;&NBSP;&NBSP; var tileName =" Chapter" + item.title +"我的图书";



        VAR瓦=新Windows.UI.StartScreen.SecondaryTile(

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; tileId ,

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; item.group.description,

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; tileName,

&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; JSON.stringify(Data.getItemReference(项)),

&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; Windows.UI.StartScreen.TileOptions.showNameOnLogo,

&NBSP;&NBSP;&NBSP;          uriLogo);



     &NBSP;&NBSP;&NBSP; tile.foregroundText = Windows.UI.StartScreen.ForegroundText.dark;

        tile.smallLogo = uriSmallLogo;

        VAR selectionRect =的document.getElementById(QUOT; pinTile")getBoundingClientRect();



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP; tile.requestCreateForSelectionAsync({X:selectionRect.left,Y:selectionRect.top,宽度:selectionRect.width,高度:selectionRect.height},Windows.UI.Popups.Placement.below).done(函数(isCreated){

       });

     ; }





})();

                        details = document.querySelector(".articlesection");
                        binding.processAll(details, items[0].data);
                        details.scrollTop = 0;
                    }
                }
            }.bind(this));
        },

        // This function toggles visibility of the two columns based on the current
        // view state and item selection.
        _updateVisibility: function () {
            var oldPrimary = document.querySelector(".primarycolumn");
            if (oldPrimary) {
                utils.removeClass(oldPrimary, "primarycolumn");
            }
            if (this._isSingleColumn()) {
                if (this._itemSelectionIndex >= 0) {
                    utils.addClass(document.querySelector(".articlesection"), "primarycolumn");
                    document.querySelector(".articlesection").focus();
                } else {
                    utils.addClass(document.querySelector(".itemlistsection"), "primarycolumn");
                    document.querySelector(".itemlist").focus();
                }
            } else {
                document.querySelector(".itemlist").focus();
            }
        },

        onDataRequested: function (e) {
            var request = e.request;
            request.data.properties.title = item.group.title + " (sent from Windows 8)";
            request.data.properties.description = "Chapter " + item.title;

            var chapText = item.content;
            // var bookDescript = item.group.description;
            var chapName = "Chapter " + item.title;
            var space = '<br><br>';
           
            var htmlFormat = Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.createHtmlFormat(chapName + space + chapText);
            request.data.setHtmlFormat(htmlFormat);
        }
    });

    function shareButtonHandler() {
        Windows.ApplicationModel.DataTransfer.DataTransferManager.showShareUI();
    }

    function pinCustomSecondaryTile() {
        var tileId = "customTile" + new Date().getTime();
        var uriLogo = new Windows.Foundation.Uri(item.backgroundImage);
        var uriSmallLogo = new Windows.Foundation.Uri("ms-appx:///images/pinned.jpg");
        var tileName = "Chapter " + item.title + " of my Book";

        var tile = new Windows.UI.StartScreen.SecondaryTile(
            tileId,
            item.group.description,
            tileName,
            JSON.stringify(Data.getItemReference(item)),
            Windows.UI.StartScreen.TileOptions.showNameOnLogo,
            uriLogo);

        tile.foregroundText = Windows.UI.StartScreen.ForegroundText.dark;
        tile.smallLogo = uriSmallLogo;
        var selectionRect = document.getElementById("pinTile").getBoundingClientRect();

        tile.requestCreateForSelectionAsync({ x: selectionRect.left, y: selectionRect.top, width: selectionRect.width, height: selectionRect.height }, Windows.UI.Popups.Placement.below).done(function (isCreated) {
        });
    }


})();

推荐答案

您需要对此进行调试,并查看激活应用程序时传递的内容。我最好的猜测是导航逻辑正在弄乱你。
You will need to debug this and see what is passed when the application is activated. My best guess is the Navigation logic is what is messing you up here.


这篇关于使用SplitView模板将Tiles固定到“开始”屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆