locked
Simple Blend Button that handles the Click in Visual Studio 2008 C (Gitch) - 12/28/2007 6:32 PM PST RRS feed

  • Question

  • By: Gitch


    I have built several of the examples that I have been able to find using 
    Blend.  I have even been able to open the project up in Visual Studio C# and 
    run the examples.  What I am not finding is the hook between Blend and C#.  I 
    want C# to know that a button was clicked and then execute c# code based on 
    that click but I can't seem to find a simple example.
    Friday, February 22, 2008 3:20 PM

Answers

  • By: Corrado Cavalli [MVP]


    Quite simple:
    1-Create a new project
    2-Drag a button on the artboard and select it
    3-On the property tab select the events list (click the lightning icon on
    the right of property name)
    4-Select the click event, type a name on textbox on right then press enter,
    Visual studio Should start
    5-Type event code

    Result is:
    <Button Click="YourEventName Content="Button" />

    public void YourEventName(object sender, RoutedEventArgs e)
    {
    / Your code here...
    }

    HTH

    --
    Corrado Cavalli [Microsoft .NET MVP-MCP]
    UGIdotNET -
    http://www.ugidotnet.org
    Weblog: http://blogs.ugidotnet.org/corrado/


    Monday, February 25, 2008 4:15 PM

All replies

  • By: Corrado Cavalli [MVP]


    Quite simple:
    1-Create a new project
    2-Drag a button on the artboard and select it
    3-On the property tab select the events list (click the lightning icon on
    the right of property name)
    4-Select the click event, type a name on textbox on right then press enter,
    Visual studio Should start
    5-Type event code

    Result is:
    <Button Click="YourEventName Content="Button" />

    public void YourEventName(object sender, RoutedEventArgs e)
    {
    / Your code here...
    }

    HTH

    --
    Corrado Cavalli [Microsoft .NET MVP-MCP]
    UGIdotNET -
    http://www.ugidotnet.org
    Weblog: http://blogs.ugidotnet.org/corrado/


    Monday, February 25, 2008 4:15 PM
  • By: Gitch


    Corrado, Thank you very much! After many hours I was able to bring up the 
    Visual Studio up by itself and get it going but your instructions allow me to 
    do it the correct an efficient way! The simple instructions you gave got me 
    up and running and opened up great numner of options.  If I manage to convert 
    my game from Java to C# and Blend I'll send you a copy. Thanks again!
    
    Gitch
    
    
    "Corrado Cavalli [MVP]" wrote:
    
    > Quite simple:
    > 1-Create a new project
    > 2-Drag a button on the artboard and select it
    > 3-On the property tab select the events list (click the lightning icon on 
    > the right of property name)
    > 4-Select the click event, type a name on textbox on right then press  enter, 
    > Visual studio Should start
    > 5-Type event code
    > 
    > Result is:
    > <Button Click="YourEventName Content="Button" />
    > 
    > public void YourEventName(object sender, RoutedEventArgs e)
    > {
    >  / Your code here...
    > }
    > 
    > HTH
    > 
    > -- 
    > Corrado Cavalli [Microsoft .NET MVP-MCP]
    > UGIdotNET - http://www.ugidotnet.org
    > Weblog: http://blogs.ugidotnet.org/corrado/
    > 
    > 
    > 
    > 
    Monday, February 25, 2008 4:17 PM
  • By: Corrado Cavalli [MVP]


    Hi Gitch,
    Glad it helped ;-)
    
    
    -- 
    Corrado Cavalli [Microsoft .NET MVP-MCP]
    UGIdotNET - http://www.ugidotnet.org
    Weblog: http://blogs.ugidotnet.org/corrado/
    
    
    
    Monday, February 25, 2008 4:17 PM