ALL SOFTWARE EXERCISES
- EXERCISES HOME PAGE (862)
- Access 2010 (66)
- Access VBA Macros (17)
- Advanced VBA (29)
- ASP.NET MVC (0)
- ASP.NET webforms - C# (25)
- ASP.NET webforms - VB (27)
- Excel 2010 (83)
- Excel 2013 (10)
- Excel 2016 (0)
- Excel VBA Macros (37)
- Power BI - Excel 2013 (25)
- Power BI - Excel 2016 (23)
- Power BI Desktop (26)
- PowerPivot 2010 (26)
- Report Builder 3.0 (42)
- SQL (156)
- SSAS - multidimensional (21)
- SSAS - tabular (29)
- SSIS Integration Services (40)
- SSRS Reporting Services (53)
- Visual Basic 2010 (42)
- Visual C Sharp 2010 (65)
- WPF - Visual C# (20)
WPF - VISUAL C# EXERCISES
Exercise: Create button styles, and inherit a base style
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
The answer to the exercise will be included and explained if you attend the course listed below!
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Add the window in the above folder into your project (or use one you created at the end of the previous exercise). When you run this as an application, you should get:
Initially the buttons at the bottom look scrunched up together and a bit dull.
The aim of this exercise is to improve the appearance of the buttons:
We'll create a default style for all buttons, then a named style which inherits this for the Exit button.
Start by creating a named style called btnStyle (and apply it to the first two buttons) to set each button's:
- background colour to something tasteful (the example uses Bisque);
- font weight to bold;
- right margin to 20 pixels;
- top and bottom padding to 5 pixels, and left/right padding to 20 pixels; and
- font size to 12 points.
The best place to do this would normally be app.xaml, as this would then apply to all windows, but for this exercise just create a resources section in the StackPanel containing the buttons.
Now create another named styled called btnExit which is based on btnStyle, but also sets a button's:
- background colour to LightCoral; and
- border brush to Maroon.
Apply the btnExit style to the 3rd button to format it:
The Exit button has the formatting of the first two, but with a different border and background colour.
Close down any windows you have open!