question

AbuRaihan-7069 avatar image
0 Votes"
AbuRaihan-7069 asked NicoZhu-MSFT commented

ProgressRing not showing when Theme changed in runtime

I am developing an UWP app. I used a ProgressRing as below code:

 <ProgressRing VerticalAlignment="Center"
               Margin="18, 0, 0, 14"
               Height="21"
               Width="21"
               IsActive="True"
               Foreground="Red"
               Visibility="Visible"/>

The progress ring is showing correctly when the parent page loads. But it is not showing when I change theme from System. Once this issue occurs, Progress Ring not shows for Light-Dark both themes. If I go back to some other pages and come back to this page again, this time progress ring shows correctly.

Can anyone please help me to work Progress Ring correctly after theme change in app runtime?


windows-uwp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

If the response is helpful, please click "Accept Answer" and upvote it.

0 Votes 0 ·

1 Answer

NicoZhu-MSFT avatar image
0 Votes"
NicoZhu-MSFT answered

Hello, Welcome to Micorosoft Q&A,

ProgressRing not showing when Theme changed in runtime

I think the problem is the ProgressRing ring animation was be destroy when you change ListViewItem's ControlTemplate by update current system theme. For this scenario, you could reload current page to rebuild this animation after the theme change.

 private void Button_Click(object sender, RoutedEventArgs e)
 {
       
     Reload();
 }
    
 public bool Reload() { return Reload(null); }
 private bool Reload(object param)
 {
     Type type = this.Frame.CurrentSourcePageType;
     if (this.Frame.BackStack.Any())
     {
         type = this.Frame.BackStack.Last().SourcePageType;
         param = this.Frame.BackStack.Last().Parameter;
     }
     try { return this.Frame.Navigate(type, param); }
     finally { this.Frame.BackStack.Remove(this.Frame.BackStack.Last()); }
 }



Usage

 public MainPage()
 {
     this.InitializeComponent();
     var Listener = new ThemeListener();
     Listener.ThemeChanged += Listener_ThemeChanged;
 }
 private void Listener_ThemeChanged(ThemeListener sender)
 {
     Reload();
 }





If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.