Now, we are going to create a new UserControl
to display a fuel gauge. We will use the previously created ScoreGauge
as a baseline to create this new gauge, making many changes.
1. Open the project
3DInvadersSilverlight
in Visual Studio or Visual C#.2. Repeat the previously explained steps to create a new gauge based on
ScoreGauge.xaml
. Instead of usingBonusGauge
as the new name, useFuelGauge
.3. Open
FuelGauge.xaml.cs
and replace the textScoreGauge
withFuelGauge
in the first lines that define the class and the constructor, as shown in the following lines:public partial class FuelGauge : UserControl { public FuelGauge()
4. Delete the
SetScore
method.5. Add the following
public
method to change the fuel level shown in the gauge:public void SetFuelLevel(int newFuelLevel) { pbgFuelLevel.Value = newFuelLevel; }
6. Now, open the project
3DInvadersSilverlight
in Expression Blend.7. Delete the
TextBlock
namedtbkScore
.8. Select
tbkLabel
and change its...