This is a migrated thread and some comments may be shown as answers.

How do you color a rectangle in C# that has been declared in XAML in WPF?

0 Answers 186 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 22 May 2010, 03:22 AM

How do you color a rectangle in C# that has been declared in XAML in WPF?

There is a rectangle control in XAML.  In my C# code there are times in which it would be nice to fill the background color.  How does one do this?

The rectangle has a text block nested inside. The Fill works to color the whole rectangle but it also blocks out the text. On the other hand, using the stroke first colors the rectangle and I can modify the enclosed test but the rectangle does not have a boarder.

The way to do it might be to bind the Rectangle background colouur to a property and use INotifyPropertyChanged to trigger the update of the colour based on the change.

How do I bind the Rectangle background colour to a property?

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
William
Top achievements
Rank 1
Share this question
or