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

Views for WPF Forum

Posted 14 years ago by Xev Xarzu
Version: 10.1.0522
Avatar
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?


[Modified at 05/22/2010 07:00 AM]

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello,

Our support is limited to our products. If you have general WPF questions, they should be posted on Microsoft's forum (http://social.msdn.microsoft.com/forums/en/wpf/threads/) or a third-party forum (such as http://www.stackoverlow.com).


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.