locked
flashing images RRS feed

  • Question

  • How do i make images appear to flash using expressions blend?
    Friday, February 13, 2009 12:32 PM

All replies

  • Add the image on the WPF form...
    <Image HorizontalAlignment="Right" x:Name="Image1" Margin="0,184.453,110,176.433" Width="107" Source="283.jpg"/> 
    and give the name to it Image1 for example.

    add a button on the form and in button click event... write the following code... create dispatcher timer. and set 1 second intervel
           private void Button1_Click(object sender, RoutedEventArgs e)  
            {  
                  
                System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();  
                dt.Interval=  new TimeSpan(0,0,1); //1 second  
                dt.Tick += new EventHandler(dt_Tick);  
                dt.Start();  
     
     
            }  
     

    in the tick event handler  make it visible true if it is false, then make it false if it is true...
            void dt_Tick(object sender, EventArgs e)  
            {  
     
                if (Image1.Visibility == Visibility.Visible)  
                    Image1.Visibility = Visibility.Hidden;  
                else 
                    Image1.Visibility = Visibility.Visible;  
             } 

    this will be flashing every second...

    I hope this will help you :)
    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Friday, February 13, 2009 6:06 PM
    Friday, February 13, 2009 6:06 PM
  •  Thank for replying.

    Sorry Im new to this.  

    What type of button do i add and where do i need to enter the code?

    i am learning expressions but i need answers in idiot terms lol
    Friday, February 13, 2009 6:49 PM
  • here is the example of xaml code for button
    <Button Height="45" Margin="226,156,300,0" Name="button2" VerticalAlignment="Top" Click="Button1_Click">Button</Button> 


    Or you can add it in window constructor.... like below example... it will blink as soon as form is loaded...
    namespace UntitledProject2  
    {  
        /// <summary>  
        /// Interaction logic for Window4.xaml  
        /// </summary>  
        public partial class Window4 : Window  
        {  
            public Window4()  
            {  
                this.InitializeComponent();  
                  
                // Insert code required on object creation below this point.  
     
                System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();  
                dt.Interval = new TimeSpan(0, 0, 1); //1 second  
                dt.Tick += new EventHandler(dt_Tick);  
                dt.Start();  
     

    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Saturday, February 14, 2009 3:55 PM
    Saturday, February 14, 2009 3:52 PM