1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Run time error (C# WPF application)

Discussion in 'Programming & Webmastering' started by MrSeanKon, Nov 23, 2012.

  1. MrSeanKon

    MrSeanKon New Member

    Joined:
    Nov 14, 2006
    Messages:
    267 (0.09/day)
    Thanks Received:
    69
    Location:
    Athens in love with Anna :)
    For button1 code works fine.
    I want after pressing button2 to be somewhere else (e.g. from position x=50, y=100 to x=200, y=300). As I understand the problem is on declarations or I misuse something.
    Any ideas to correct the code? :rolleyes:
     

    Attached Files:

  2. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,954 (6.25/day)
    Thanks Received:
    3,788
    Location:
    IA, USA
    Use breaks to catch an error before WPF implodes itself. On doing so, I discovered both your MarginProperty and BorderThicknessProperty want a ThicknessAnimation, not a DoubleAnimation so, I changed it and it appears to work:
    Code:
                ThicknessAnimation myanimation = new ThicknessAnimation(new Thickness(0), new Thickness(100), TimeSpan.FromMilliseconds(1000));
    
                // Both statements produce run time error!
                
                button2.BeginAnimation(Button.MarginProperty,myanimation);
                button2.BeginAnimation(Button.BorderThicknessProperty,myanimation);      
     
    MrSeanKon says thanks.
    Crunching for Team TPU
  3. MrSeanKon

    MrSeanKon New Member

    Joined:
    Nov 14, 2006
    Messages:
    267 (0.09/day)
    Thanks Received:
    69
    Location:
    Athens in love with Anna :)
    Yeap it is a good idea to use try/catch blocks for making robust applications.
    BTW I ran the code before under VS 2010 debugger and saw an exception, but since I am a newbie :D I could not understand :wtf: the message mean...
    I am writing the first lines in WPF C# enviroment. I want to improve my old Windows Form based cardgames. Obviously I am not familiar, but after a couple of days hope so!
    Thank you very much :)
     
  4. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,881 (4.87/day)
    Thanks Received:
    5,616
    Location:
    Cheeseland (Wisconsin, USA)
    Switching from Windows Forms programming to WPF (C#/XAML) will give you many headaches.
    Stick with it, though, as the advantages are worth the effort.
     

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page