Can't animate Color property of SolidColorBrush

Polat Pınar 26 Reputation points
2020-11-19T19:34:38.587+00:00

Hello,
Is there a way to animate Color property of SolidColorBrush from color1 to color2?
Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. mc 3,681 Reputation points
    2020-11-20T00:25:36.497+00:00

    I think you can use

    Device.StartTimer

    To change the color .

    otherwise The animation seems that can not change the color.


  2. JarvanZhang 23,936 Reputation points
    2020-11-20T02:10:53.023+00:00

    @Polat Pınar Do you mean change the Color's value of the SolidColorBrush? I tested a basic demo about the function, it work fine. Here is the related code, you could refer to it.

    Specify a value to brush in code behind.

       <Button Clicked="Button_Clicked" .../>  
       <Frame x:Name="frame"...>  
           <Frame.Background>  
               <SolidColorBrush Color="{Binding TheBackground}" />  
           </Frame.Background>  
       </Frame>  
         
       private void Button_Clicked(object sender, EventArgs e)  
       {  
           frame.Background = Brush.DeepPink;  
       }