[.net] I am having some basic compile issues defining a BorderBrush.

Started by
2 comments, last by Nikster 12 years, 6 months ago
I am having some basic compile issues defining a BorderBrush.

http://msdn.microsoft.com/en-us/library/system.windows.controls.border.borderbrush.aspx
states that you define a borderbrush like this:

myBorder1 = new Border();
myBorder1.BorderBrush = Brushes.SlateBlue;


but in my code, when I try
border1.BorderBrush = Brushes.SlateBlue;
I get
Error 1 The name 'Brushes' does not exist in the current context
and I have included the namespace
System.Windows.Controls
as a "using" statement at the top of the file
as well as a Reference to the project.
What am I missing?
Advertisement
It uses System.Windows.Media.Brush so you'd need the Sytem.Windows.Media namespace rather than System.Windows.Controls (which is where the Brushes are actually contained)

If you're still having problems, have a look at the bottom of that link you posted.
The information on the bottom of that page works.
border2.BorderBrush = new SolidColorBrush(Colors.Green);
works

I wonder why
border2.BorderBrush = new SolidColorBrush(Colors.Lime);
does not work since "Lime" is an option color in XAML but not in CS
Color.Lime from System.Drawing
Colors.Lime from System.Windows.Media


It's hard to tell what you're trying to do with one line, what you're compiling for (.net version) and whether you're using just c# forms with no wpf etc.

This topic is closed to new replies.

Advertisement