简体   繁体   English

Windows Phone 8中的数据透视页无法触发LoadedPivot事件?

[英]pivot page in windows phone 8 LoadedPivot event not firing?

i just started with generic forms for windows phone 8 development. 我刚开始使用Windows Phone 8开发的通用形式。 No i want to test if a certain pivotitem is selected, then it should fire a function to load a grid into that pivot item. 不,我不想测试是否选择了某个枢轴项目,那么它应该触发将网格加载到该枢轴项目中的功能。

here is my xaml and my code so far XAML: 这是我的xaml和到目前为止的代码XAML:

 <phone:Pivot Name="mainpivot" Title="MY APPLICATION" LoadingPivotItem="mainpivot_LoadingPivotItem" LoadedPivotItem="mainpivot_LoadedPivotItem_1">
        <!--Pivot item one-->
        <phone:PivotItem Name="staticpivot" Header="static">
            <!--Double line list with text wrapping-->
            <Grid Name="staticGrid" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>



                </Grid.RowDefinitions>

                <TextBox Name="txtUsername" Grid.Column="1" Height="70"></TextBox>
                <TextBox Name="txtPassword" Grid.Row="1" Height="70" Grid.Column="1"></TextBox>
                <TextBox Name="txtdescription" Grid.Row="2" Height="150"  Grid.Column="1" TextWrapping="Wrap"></TextBox>


                <TextBlock Height="40" Text="USERNAME" HorizontalAlignment="Center"></TextBlock>
                <TextBlock Height="40" Text="PASSWORD" HorizontalAlignment="Center" Grid.Row="1"></TextBlock>
                <TextBlock Height="40" Text="DESCRIPTION" HorizontalAlignment="Center" Grid.Row="2"></TextBlock>

                <Button Grid.Row="4" Grid.ColumnSpan="2" Tap="Button_Tap">SAVE DATA</Button>
            </Grid>
        </phone:PivotItem>

        <!--Pivot item two-->
        <phone:PivotItem x:Name="genericpivot" Header="generic">
            <!--Double line list no text wrapping-->
        </phone:PivotItem>
    </phone:Pivot>

as you can see the 2nd pivot has nothing in it, i am going to populate it dynamically with controls. 如您所见,第二个枢轴没有任何内容,我将使用控件动态填充它。

the problem is here in the code : 问题在代码中:

        private void mainpivot_LoadedPivotItem_1(object sender, PivotItemEventArgs e)
    {
        if (e.Item.Name == "genericpivot")
        {
            loadDetailForPivot();
        }
    }

this function does not fire when i debug and put a breakpoint there. 当我调试并在其中放置断点时,此功能不会触发。 can anyone tell my why? 谁能告诉我为什么? or give a link that explains it. 或提供解释它的链接。

regards 问候

To clarify, are you trying to populate the selected pivot item once it's selected? 为澄清起见,您是否在选择选定的枢纽项目后尝试对其进行填充?

I believe what you are after is picking up a change to the pivot controls selectedindex, such as (VB.net, sorry): 我相信您所追求的是对枢纽控件selectedIndex的更改,例如(VB.net,很抱歉):

  Private Sub PivotItem_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles PivotItem.SelectionChanged
       If PivotItem.SelectedIndex = 1 Then LoadDetailForPivot
End Sub

However...why do you not load the controls beforehand? 但是...为什么不事先加载控件? Wouldn't that be quicker (ie no delay while things are loaded as the user pivots). 这样不是更快(例如,随着用户的旋转,加载东西时没有延迟)。 I did this on a previous app and the pivoting was jerky as a result. 我是在以前的应用程序上执行此操作的,结果造成了枢转。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM