[英]How to Determine Which Pivot Item is Navigated To Most Often
I am using a Pivot Control which contains 5 Pivot Items on a page. 我使用的数据透视控件在页面上包含5个数据透视项。 The user can only swipe right or left to get to these, but from the starting pivot, index = 0, I'd like to be able to determine which direction, and how far in that direction, a user generally goes.
用户只能向右或向左滑动才能到达这些位置,但是从起始枢轴index = 0,我希望能够确定用户通常向哪个方向以及该方向走了多远。 Since each of my pivots is loading several pieces of data, and the user can swipe either left or right from the starting index, my ultimate goal is to determine how often a user goes in either direction, and how far, and load those pivot items first.
由于我的每个数据透视表都在加载几条数据,并且用户可以从起始索引向左或向右滑动,所以我的最终目标是确定用户在任一方向上走的频率,走多远并加载这些数据透视表项目第一。 For Instance, If my pivots are
例如,如果我的枢纽是
MainPage.xaml MainPage.xaml
<phone:Pivot x:Name="myPivot">
<phone:PivotItem Header="one"/>
<phone:PivotItem Header="two"/>
<phone:PivotItem Header="three"/>
<phone:PivotItem Header="four"/>
<phone:PivotItem Header="five"/>
</phone:Pivot>
MainPage.xaml.cs MainPage.xaml.cs
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
await RenderAsync();
}
private async Task RenderAsync()
{
if (!Busy)
{
Busy = true;
int side = 136;
try
{
using (Bitmap bitmap = await App.Model.RenderBitmapAsync(side))
{
if (Settings.LoadDynamically.Value == false)
{
await RenderAsync(bitmap, side, App.Model.One, OneWrapPanel);
await RenderAsync(bitmap, side, App.Model.Two, TwoWrapPanel);
await RenderAsync(bitmap, side, App.Model.Three, ThreeWrapPanel);
await RenderAsync(bitmap, side, App.Model.Four, FourWrapPanel);
await RenderAsync(bitmap, side, App.Model.Fiv, FiveWrapPanel);
}
else
{
//Custom order goes here, load best order
}
}
}
catch (Exception)
{
NavigationService.GoBack();
}
Busy = false;
}
}
where the first pivot item is index of 0 and the fifth is index of 4, from the first pivot I'd like to be able to determine how many times the user navigates to pivot 5 (to the left) and to pivot two (the right). 从第一个枢纽开始,第一个枢纽项目的索引为0,第五个索引为4,我希望能够确定用户导航到枢轴5(向左)和枢纽两次(对)。 From here, I'd again like to know how many times the user keeps going in that direction.
从这里开始,我再次想知道用户一直朝着这个方向前进了多少次。 So if the user went to 5 and then 4, and also from two to three.
因此,如果用户转到5,然后转到4,又从两个到三个。 Once this data is gathered, I'd like to be able to determine, possibly by setting some sort of weight for each situation, the best order to load each pivot item.
收集了这些数据后,我希望能够确定(可能通过为每种情况设置某种权重)加载每个枢纽项目的最佳顺序。
There is no other way, I think. 我认为没有其他办法。 It's very easy:
这很简单:
private void appPivot_LoadedPivotItem(object sender, PivotItemEventArgs e)
{
startUse = DateTime.Now;
}
private void appPivot_UnloadingPivotItem(object sender, PivotItemEventArgs e)
{
TimeSpan pivotUsage = DateTime.Now - startUse;
// Save it somewhere regarding to SelectedPivotItem
}
But changing the order isn't recommended in the metro design guidance(as I remember), however I personally think that it's a good idea. 但建议不要在Metro设计指南中更改顺序(我记得),但是我个人认为这是个好主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.