Answered by:
UserControl Border background brush set in code, but I don't see that color at run-time

Question
-
Given the code below, I set the containing Border element on my UserControl to the given background color if a background color is given by the caller. If I change the background Brush manually in the designer, I do see that color at run-time. However, if I do it via the code below, I don't see any color (the Border background color is the same as the current Window). Why doesn't setting it from code at run-time work?
public RateMyApp( string ratingMsg, string sendFeedbackEmailAddr, string rateAndReviewUrl, Color? backgroundColor = null) { this.InitializeComponent(); if (String.IsNullOrWhiteSpace(ratingMsg)) throw new ArgumentNullException("The rating message is empty."); if (String.IsNullOrWhiteSpace(sendFeedbackEmailAddr)) throw new ArgumentNullException("The send feedback E-mail address is empty."); if (String.IsNullOrWhiteSpace(rateAndReviewUrl)) throw new ArgumentNullException("The rate and review URL is empty."); this.RatingMessage = ratingMsg; this.SendFeedbackEmailAddr = sendFeedbackEmailAddr; this.RateAndReviewUrl = rateAndReviewUrl; if (backgroundColor != null) this.BorderBrush = new SolidColorBrush(backgroundColor.Value); // Show the question stack panel and hide the rate & review and send feedback stack panels. gridQuestion.ShowElement(true); gridRateAndReview.HideElement(true); gridSendFeedback.HideElement(true); }
-- roschler
Tuesday, March 4, 2014 7:06 PM
Answers
-
Hi roschler,
You have a border in your user control, whats the name of the border control? I saw you set the BorderBruch for "this", and "this" means the UserControl but not the border control
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- Edited by Jamles HezModerator Wednesday, March 5, 2014 4:05 AM
- Marked as answer by roschler Wednesday, March 5, 2014 4:41 AM
Wednesday, March 5, 2014 3:20 AMModerator
All replies
-
Hi roschler,
You have a border in your user control, whats the name of the border control? I saw you set the BorderBruch for "this", and "this" means the UserControl but not the border control
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- Edited by Jamles HezModerator Wednesday, March 5, 2014 4:05 AM
- Marked as answer by roschler Wednesday, March 5, 2014 4:41 AM
Wednesday, March 5, 2014 3:20 AMModerator -
Thanks Jaime. That was it. Tired eyes I guess. :)
-- roschler
Wednesday, March 5, 2014 4:41 AM