TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
David Marshall
NA
1
1.9k
Petzold code problem
May 23 2013 7:38 PM
I'm trying to run the following code (pages 32-33 of Petzolds Programming Windows 6th Edition)
using MSVS2012 Pro on Windows 8 Pro 64-bit.
(first excerpt from MainPage.xaml
<Grid Name="contentGrid"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Name="txtblk"
Text="Hello, Windows 8!"
FontSize="96"
FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
(second excerpt from MainPage.xaml.cs)
public MainPage()
{
this.InitializeComponent();
// Create the foreground brush for the TextBlock
LinearGradientBrush foregroundBrush = new LinearGradientBrush();
foregroundBrush.StartPoint = new Point(0, 0);
foregroundBrush.EndPoint = new Point(1, 0);
GradientStop gradientStop = new GradientStop();
gradientStop.Offset = 0;
gradientStop.Color = Colors.Blue;
foregroundBrush.GradientStops.Add(gradientStop);
gradientStop = new GradientStop();
gradientStop.Offset = 1;
gradientStop.Color = Colors.Red;
foregroundBrush.GradientStops.Add(gradientStop);
txtblk.Foreground = foregroundBrush;
// Create the background brush for the Grid
LinearGradientBrush backgroundBrush = new LinearGradientBrush
{
StartPoint = new Point(0, 0),
EndPoint = new Point(1, 0)
};
backgroundBrush.GradientStops.Add(new GradientStop
{
Offset = 0,
Color = Colors.Red
});
backgroundBrush.GradientStops.Add(new GradientStop
{
Offset = 1,
Color = Colors.Blue
});
contentGrid.Background = backgroundBrush;
}
I get the following errors:
Error 1 The name 'Colors' does not exist in the current context C:\TestProjects\Petzold
\GradientBrushCode\GradientBrushCode\MainPage.xaml.cs 34 34 GradientBrushCode
Error 2 The name 'Colors' does not exist in the current context C:\TestProjects\Petzold
\GradientBrushCode\GradientBrushCode\MainPage.xaml.cs 38 34 GradientBrushCode
Error 3 The name 'Colors' does not exist in the current context C:\TestProjects\Petzold
\GradientBrushCode\GradientBrushCode\MainPage.xaml.cs 50 25 GradientBrushCode
Error 4 The name 'Colors' does not exist in the current context C:\TestProjects\Petzold
\GradientBrushCode\GradientBrushCode\MainPage.xaml.cs 55 25 GradientBrushCode
I searched and found similar posts that suggest adding:
using System.Drawing
I tried that but got another compiler error:
Error 1 The type or namespace name 'Drawing' does not exist in the namespace 'System' (are
you missing an assembly reference?) C:\TestProjects\Petzold\GradientBrushCode\GradientBrushCode
\MainPage.xaml.cs 2 14 GradientBrushCode
I have no idea what to do.
Please help.
David
Reply
Answers (
3
)
is there a memory limit for the dispatcher
Implement arrary sorting Using Insertion Sort