首页 \ 问答 \ 在WP7中处理双向导航?(Handling two way navigation in WP7?)

在WP7中处理双向导航?(Handling two way navigation in WP7?)

基本上当我的应用程序加载我的第一个屏幕是MainPage.xaml,我将其视为加载屏幕。 这是为了让屏幕更新出现得更快。 从加载屏幕中,用户自动导航到另一个页面,该页面分别包含名为Content.xaml的内容。

问题是导航的第一种方式正常工作,

SpashScreenImage - > MainPage.xaml - > Content.xaml

但是如果用户决定点击后退按钮,他们将进入加载页面,但是随后导航回到内容页面。

MainPage.xaml < - Content.xaml
MainPage.xaml - > Content.xaml

如果我知道他们来自哪个页面,这看起来很容易解决。 有没有办法检测用户正在浏览的页面? 这样我就可以正确处理它。

编辑:我的主要目标是获取当您导航到WP7中的全景页面时发生的动画(幻灯片效果)。 到目前为止,我能够触发此事件的唯一方法是手动导航到页面,就像我在我的问题(Content.xaml == Panorama Page)中所建议的那样,或者通过重新激活该页面上的应用程序。


basically when my app loads my first screen is MainPage.xaml, which I'm treating as a loading screen. This is to make an update to screen appear faster. From the loading screen the user is automatically navigated to another page that contains content called Content.xaml respectively.

The problem is navigating the first way works fine,

SpashScreenImage --> MainPage.xaml --> Content.xaml

but if the user decides to hit the back button they go to the loading page, but then that navigates them back to the content page.

MainPage.xaml <-- Content.xaml
MainPage.xaml --> Content.xaml

This looks real easy to solve if I knew what page they were coming from. Is there a way to detect what page the user is navigating from? That way I could handle it properly.

EDIT: My main objective is to get the animation that occurs when you navigate to a Panorama page in WP7 (Slide effect). So far the only way I've been able to trigger this event is by manually navigating to the page, like I suggested in my question (Content.xaml == Panorama Page), or by reactivating the app on that page.


原文:https://stackoverflow.com/questions/5508824
更新时间:2023-05-25 21:05

最满意答案

您可以使用:contains选择器,但它不使用完全匹配条件,即如果将Col 1传递给选择器并且其中一个元素具有Col 12文本内容,则它将选择该元素,因为它包含指定的文本。 我使用filter方法:

var hasColumn = $('#mytable thead th').filter(function() {
   return this.textContent === 'Col 1';
}).length > 0;

这是一个vanilla JavaScript替代方案:

function hasColumn(tblSel, content) {
    var ths = document.querySelectorAll(tblSel + ' th');
    return Array.prototype.some.call(ths, function(el) {
         return el.textContent === content;
    });
};

var hasCol = hasColumn('#mytable', 'Col 1');

You could use the :contains selector but it doesn't use the exact match criterion, i.e. if you pass Col 1 to the selector and one of the elements has Col 12 text content then it will select that element as it contains the specified text. I'd use the filter method:

var hasColumn = $('#mytable thead th').filter(function() {
   return this.textContent === 'Col 1';
}).length > 0;

Here is a vanilla JavaScript alternative:

function hasColumn(tblSel, content) {
    var ths = document.querySelectorAll(tblSel + ' th');
    return Array.prototype.some.call(ths, function(el) {
         return el.textContent === content;
    });
};

var hasCol = hasColumn('#mytable', 'Col 1');

相关问答

更多
  • 为了达到我的目标(如问题所述),我写了下面的代码 - 这是我写的插件。 (function ($) { $.fn.scrollbarTable = function (i) { var o = {}; if (typeof (i) == 'number') o.height = i; else if (typeof (i) == 'object') o = i; else if (typeof (i) == 'undefined') o = { ...
  • 您可以使用:contains选择器,但它不使用完全匹配条件,即如果将Col 1传递给选择器并且其中一个元素具有Col 12文本内容,则它将选择该元素,因为它包含指定的文本。 我使用filter方法: var hasColumn = $('#mytable thead th').filter(function() { return this.textContent === 'Col 1'; }).length > 0; 这是一个vanilla JavaScript替代方案: function hasC ...
  • 使用rowspan ,您不必在下一行中添加列(或者行数减去一行 )。 您的演示版已更新 :
  • this.tagName将告诉您具有哪种元素类型。 jQuery对象没有tagName属性。 this.tagName will tell you which element type you have. jQuery object doesn't have tagName property.
  • 如果您只需检查表是否包含特定行,您可以这样做: if($("#rowID").length){ //Horray you have the row you specified. } else{ //what you should do when the row doesn't exist } 请注意, if($("#rowID").length)暗示元素的长度不等于零,这意味着它存在,您还可以更改您想要选择元素的方式,您可以执行类似$("#tableID tr").length 。 我希望这可 ...
  • 这是因为你给了你的container width:200px; 给它width:220px; 或根本没有宽度可以适当调整table 。
    Its because you've given your container a width:200px; Give it either a width:220px; or no width at all to adjust it ...
  • 如果我看得正确,带有“责任公司律师姓名”的表格在TH标签内。 那个TH标签有CSS类“ms-vh”。 因此,如果你应用这个TH的宽度,它应该工作。 If I see correctly, the table with "Name of Company lawyer with responsibility" is inside a TH tag. And that TH tag has CSS class "ms-vh". So if you apply the width for this TH, it s ...
  • 在你的例子中使用下面的表格。 $("#sampletable tbody").append(rows); #表示您希望查找的ID,并且您的jQuery示例中包含tblCustomers。 Use the following for that table in your example. $("#sampletable tbody").append(rows); the # represents the ID you wish to find and you have tblCustomers in yo ...
  • Items Type Values Date