Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3844638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:07:14+00:00 2026-05-19T16:07:14+00:00

I have a control with white text foreground color and transparent background color. Later

  • 0

I have a control with white text foreground color and transparent background color.
Later on this usercontrol will be added into a different control that carries the real background color.

However during designing this, control due white foreground on white background in VS 2010, I can’t obviously see anything. In there anyway to define a different color for just the design time?

I have tried this:

if (System.ComponentModel.DesignerProperties.IsInDesignTool)
{
    LayoutRoot.Background = new SolidColorBrush(Colors.Blue);
}

But this doesn’t work. Any tips?

UPDATE:

I dont understand how this works for you guys. I have created a new Silverlight 4.0 Application and have inserted this line of code into the ctor:

public MainPage()
        {
            InitializeComponent();
            LayoutRoot.Background = new SolidColorBrush(Colors.Blue);

        }

<UserControl x:Class="SilverlightApplication3.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot">

    </Grid>
</UserControl>

When I go into Designer, I still dont see it as blue. And I dont even have any isInDesignTime Condition there. What I am missing here?

Thanks,
Kave

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:07:15+00:00Added an answer on May 19, 2026 at 4:07 pm

    Here’s one way:

    if (System.ComponentModel.DesignerProperties.IsInDesignTool)
    {
        LayoutRoot.Background = new SolidColorBrush(Colors.Yellow);
    }
    

    If you switch to creating a templated control, you’ll need to wait to set things up in OnApplyTemplate, like in this example:

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        Border b = this.GetTemplateChild("backBorder") as Border;
        if (b != null && System.ComponentModel.DesignerProperties.IsInDesignTool)
        {
            b.Background = new SolidColorBrush(Colors.Orange);
        }
    }
    

    Assuming this is the template:

    <Style TargetType="local:TemplatedControl1">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:TemplatedControl1">
                    <Border x:Name="backBorder"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

    I also like to add conditional compile directives around code like this, as it’s only for the developer/designer and is never needed at run-time.

    #if DEBUG
    if (System.ComponentModel.DesignerProperties.IsInDesignTool)
    {
        LayoutRoot.Background = new SolidColorBrush(Colors.Yellow);
    }
    #endif
    

    Note that this entire technique works only when the UserControl you’re creating is used within* another* UserControl/Control at design time. So, if the code I suggested above is placed in a UserControl named UserControlWithDesignMode, then you must have another UserControl, UserControlHost, that contains an instance of the UserControlWithDesignMode control to see the behavior work at design time. The code-behind for the currently edited control does not execute when you’re editing it. It only executes when it’s contained within another host (in Silverlight, another UserControl for example).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ToggleSwitch control and the header text is white. The Off and
What source control products have a diff facility that ignores white space, braces, etc.,
So I have a Silverlight control that I've added to an ASP.NET Web Forms
I have a repeater control and in each cell there is some text, bid
I have a ASP text box control. When the user focuses on text box,
I have a tree view control build dynamically. i want to change color of
I have this interface with multiple UILabels. On view loading i populate white labelled
I have this bar chart control on my web page, I am adding at
xml.append(<alertDesc>); xml.append(desc); xml.append(</alertDesc>); response.getWriter().write(xml.toString()); response.setContentType(text/xml); response.setHeader(Cache-Control, no-cache); xml is a StringBuffer object. I have
I have been using Git for my version control for a while now, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.