|
-
Dec 11th, 2011, 04:41 PM
#3
Thread Starter
Addicted Member
Re: Could someone answer some basic WPF questions?
 Originally Posted by boops boops
Hi RadX,
I can answer your second question: quite a few things in the code-behind are pretty similar to WinForms, and IntelliSense helps you a lot. If you add a button in the designer, you can double-click it to get a boilerplate handler for it in the window's xaml.cs file. Then you could button1's click handler, for example, like this:
Code:
private void button1_Click(object sender, RoutedEventArgs e)
{
button1.Background = Brushes.Gold;
button2.Background = Brushes.Blue;
button3.Background = Brushes.Blue;
}
... and similarly for button2 and button3.
Alternatively you could declare the buttons in the code, and assign click handlers in the initialization. Intellisense practically writes it for you:
Code:
public Window1()
{
InitializeComponent();
button1.Click+=new RoutedEventHandler(button1_Click);
///etc.
}
Obviously, some things are different, such defining the Background as Brush instead of the BackgroundColor as a Color. Once again, Intellisense helps you.
BB
Ok, but I want a gradient gold background when a button is clicked. I have a saved storyboard that turns the background into a gold gradient. How do I begin that from the code?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|