0
I have a ProgressRing
which must be displayed while a list of accounts is loaded into a DataGrid
:
<Grid>
<ProgressRing x:Name="CarregamentoDeContas" />
<controls:DataGrid
x:Name="DataGridDeContas"
AutoGenerateColumns="True"
ItemsSource="{x:Bind Contas}" />
</Grid>
code-Behind:
private List<Conta> Contas;
private void ObterListaDeContas()
{
try
{
CarregamentoDeContas.IsActive = true;
Contas = ListaDeContas.ObterContas();
}
finally
{
CarregamentoDeContas.IsActive = false;
}
}
public ContasPage()
{
this.InitializeComponent();
ObterListaDeContas();
}
When running the application, the data is loaded but Progressring is not displayed. What I am doing wrong?
Joao, I went to see an example of use and found one that arrow the visibility of Progressring:
CarregamentoDeContas.Visibility = Visibility.Visible;
– Rodrigo Tognin
@Rodrigotognin, thanks for the comment. I put the snippet inside the
try
and it brought the CS0176 error The member "Visibility.Visible" cannot be accessed with an instance reference; qualify it with a type name. I set the property in control, which removes the error, but still does not display theProgressRing
.– user57493
Joao, I saw the example on this site: https://www.tutorialspoint.com/xaml/xaml_progressring.htm - Suddenly you can take a look and see if there is something missing.
– Rodrigo Tognin
I found something else here, João. Add this library to your project:
using Windows.UI.Xaml;
– Rodrigo Tognin
The library is already included, @Rodrigotognin. And the example is the same as in Windows Community Toolkit Sample App. I believe the problem is in
try
; I believe that if I put it in an asynchronous method I will succeed.– user57493