当前位置: 代码迷 >> Windows Mobile >> 进度条的开启和关闭有关问题
  详细解决方案

进度条的开启和关闭有关问题

热度:4   发布时间:2016-04-25 07:26:33.0
进度条的开启和关闭问题
想要的结果是:删除列表中的第n条记录时,显示进度条,删除完毕并作相应处理后关闭进度条。但我如下做法却实现不了。具体是:用ApplicationBar中的按钮(如btnBegin、btnEnd)可实现进度条的开启和关闭,但在ListBox中的按钮(如deleteTaskButton_Click)却不能实现进度条的开启和关闭。个人感觉是ListBox中的按钮调用不了其外面的控件progressBar,我也不知道如何调用。请高手指点。

/*页面部分代码*/
   <!--LayoutRoot 是包含所有页面内容的根网格-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <!--TitlePanel 包含应用程序的名称和页标题-->
        <StackPanel Grid.Row="0" Margin="12,0,12,0">
            <helpers:ProgressBarWithText Name="progressBar"
                Text="正在处理..." 
                ShowProgress="{Binding ElementName=currPage, Path=ShowProgress}" 
                />
        </StackPanel>

                <ListBox x:Name="listPrincipleView" Margin="0,2,0,0" ItemsSource="{Binding}"  ItemTemplate="{StaticResource PrincipleContentTemplate}" />

     </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button1" Click="btnBegin"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button2" Click="btnEnd"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>


/*后台可实现进度条开启和关闭的部分代码*/

        private void btnBegin(object sender, EventArgs e)
        {
            progressBar.ShowProgress = true;
        }


        private void btnEnd(object sender, EventArgs e)
        {
            progressBar.ShowProgress = false;
        }


/*后台不能实现进度条开启和关闭的部分代码,下面的按钮在temTemplate="{StaticResource PrincipleContentTemplate}" 中已定义*/


        private void deleteTaskButton_Click(object sender, RoutedEventArgs e)
        {

            var button = sender as Button;
  相关解决方案