ProgressRing从不显示

时间:2016-03-08 21:42:14

标签: windows-phone-8.1

我创建了一个页面,我在其中放置了Grid上面的内容:

<ProgressRing x:Name="Ring" HorizontalAlignment="Center" VerticalAlignment="Center" IsEnabled="True"/>

但是当我在代码中Ring.IsActive = true;时,没有任何反应!可能我在这里遗漏了一些非常简单的东西,但我无法弄清楚它是什么。

这是我的xaml:

<Page
    x:Class="Diakopes_v2._0.AddExpense"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Diakopes_v2._0"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" Background="#FF0277BD">
    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Icon="Accept" Label="Accept" Click="Accept_Click"/>
            <AppBarButton Icon="Cancel" Label="Cancel" Click="Cancel_Click"/>
        </CommandBar>
    </Page.BottomAppBar>

    <Grid>
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FF0277BD" Offset="0"/>
                <GradientStop Color="#FFE1F5FE" Offset="1"/>
            </LinearGradientBrush>
        </Grid.Background>

        <TextBlock Text="New Expense" TextAlignment="Center" FontSize="46" FontFamily="/Assets/Fonts/BebasNeue Bold.ttf#Bebas Neue"></TextBlock>
        <StackPanel HorizontalAlignment="Left" Height="564" Margin="0,76,0,0" VerticalAlignment="Top" Width="400">
            <TextBox x:Name="Name" PlaceholderText="Name"></TextBox>
            <TextBox x:Name="Price" InputScope="Number" PlaceholderText="Price"></TextBox>
        </StackPanel>
        <ProgressRing x:Name="Ring" HorizontalAlignment="Center" VerticalAlignment="Center" IsEnabled="True"/>
    </Grid>
</Page>

这是我的.cs方法我想使用ProgressRing

private void Accept_Click(object sender, RoutedEventArgs e) {
    Ring.IsActive = true;
    Name.Text = Name.Text.Trim();
    Price.Text = Price.Text.Trim();

    DBHelper dbHelper = new DBHelper();

    Price.Text = Price.Text.Replace(",", ".");
    ExpensesTable NewExpense = new ExpensesTable(Place.Id, Name.Text, Convert.ToSingle(Price.Text));
    dbHelper.InsertExpense(NewExpense);

    Ring.IsActive = false;

    Frame.Navigate(typeof(Expenses), Place.Name);
}

1 个答案:

答案 0 :(得分:0)

我刚刚使用您提供的简单修改代码创建了示例:

开启:

private void Accept_Click(object sender, RoutedEventArgs e)
{
    Ring.IsActive = true;
}

关闭:

private void Cancel_Click(object sender, RoutedEventArgs e)
{
    Ring.IsActive = false;
}

查看模拟器的截图:

enter image description here

此外,要删除黑色矩形,您应将Background属性更改为Transparent

所以,我猜你的代码运行得如此之快,以至于你没有时间看看它是如何工作的ProgressRing