找到你要的答案

Q:Windows Phone 8.1 app ProgressRing not showing

Q:Windows Phone 8.1应用progressring不显示

I am trying to show a progressring while storing data but I can not get it to show. My Xaml looks as follows:

 <Page
    x:Class="MyApp.MyPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Model="using:MyApp.Model"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.BottomAppBar>
        <CommandBar Height="58">
            <AppBarButton Icon="Save" Label="" Click="AddAppBarButton_Click"/>
        </CommandBar>
    </Page.BottomAppBar>


    <Grid x:Name="LayoutRoot">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Title Panel -->
        <StackPanel Grid.Row="0" Margin="19,0,0,0">
            <TextBlock Text="Name" Style="{ThemeResource BaseTextBlockStyle}" Margin="0,12,0,0"/>
            <TextBox x:Name="nameTextBox" Margin="0,10,21.833,0" />
            <TextBlock Text="Item" Style="{ThemeResource BaseTextBlockStyle}" Margin="0,12,-4.167,0"/>
            <TextBox x:Name="itemTextBox" Margin="0,10,96.833,0" PlaceholderText="" Grid.ColumnSpan="2" />
                <AppBarButton Grid.Column="1" HorizontalAlignment="Left" Icon="AddFriend" Label="" Margin="88.167,-2,0,0" VerticalAlignment="Top" Height="66" Click="ItemAppBarButton_Click"/>
            <Grid Margin="0,0,-0.167,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
            </Grid>
            <ListView x:Name="ItemListView" Height="379" Margin="0,10,21.833,0" IsItemClickEnabled="True" ItemClick="ItemListView_ItemClick">
                <ListView.DataContext>
                    <Model:Person/>
                </ListView.DataContext>
            </ListView>
        </StackPanel>
        <ProgressRing Name="BusyProgressRing" HorizontalAlignment="Left" Margin="169,299,0,0" VerticalAlignment="Top"/>
    </Grid>
</Page>

When I do:

BusyProgressRing.IsActive = true;

It does not show. Because at the end of my member function I do a BusyProgressRing.IsActive = false; and the rendering of the ring only occurs after my whole function is done.

Does anyone know how to solve this?

我试图说明的一个progressring而存储数据,但我不能让它显示。我的XAML如下:

 <Page
    x:Class="MyApp.MyPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Model="using:MyApp.Model"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.BottomAppBar>
        <CommandBar Height="58">
            <AppBarButton Icon="Save" Label="" Click="AddAppBarButton_Click"/>
        </CommandBar>
    </Page.BottomAppBar>


    <Grid x:Name="LayoutRoot">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Title Panel -->
        <StackPanel Grid.Row="0" Margin="19,0,0,0">
            <TextBlock Text="Name" Style="{ThemeResource BaseTextBlockStyle}" Margin="0,12,0,0"/>
            <TextBox x:Name="nameTextBox" Margin="0,10,21.833,0" />
            <TextBlock Text="Item" Style="{ThemeResource BaseTextBlockStyle}" Margin="0,12,-4.167,0"/>
            <TextBox x:Name="itemTextBox" Margin="0,10,96.833,0" PlaceholderText="" Grid.ColumnSpan="2" />
                <AppBarButton Grid.Column="1" HorizontalAlignment="Left" Icon="AddFriend" Label="" Margin="88.167,-2,0,0" VerticalAlignment="Top" Height="66" Click="ItemAppBarButton_Click"/>
            <Grid Margin="0,0,-0.167,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
            </Grid>
            <ListView x:Name="ItemListView" Height="379" Margin="0,10,21.833,0" IsItemClickEnabled="True" ItemClick="ItemListView_ItemClick">
                <ListView.DataContext>
                    <Model:Person/>
                </ListView.DataContext>
            </ListView>
        </StackPanel>
        <ProgressRing Name="BusyProgressRing" HorizontalAlignment="Left" Margin="169,299,0,0" VerticalAlignment="Top"/>
    </Grid>
</Page>

当我做:

BusyProgressRing.IsActive = true;

它不显示。因为在我的成员函数结束我做busyprogressring.isactive = false;圆环的绘制只发生在我的整个功能了。

有人知道如何解决这个问题吗?

answer1: 回答1:

Yes, because ProgressRing does not appears in design time. It appears just in Runtime. You will see it when you deploy the application.

Additionally, ProgressRing always appears in the center of the screen. You don't have to write code for this.

是的,因为progressring不出现在设计时。它似乎只是在运行时。部署应用程序时会看到它。

此外,progressring总是出现在屏幕的中心。您不必为此编写代码。

answer2: 回答2:

Tested your code and the ProgressRing works. I did remove the margins and correct issue with row/column position of some UI element in your code and add

IsActive = "True"

to the ProgressRing. Your original code (with the margins) puts ProgressRing outside visible area when tested on my desktop.

测试你的代码和progressring作品。我确实删除了代码中的一些UI元素的行/列位置的边距和正确的问题,并添加

IsActive = "True"

到progressring。你的原代码(和利润)提出progressring外可见区域在我的桌面上进行测试时。

windows  xaml  phone