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 7052589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:24:06+00:00 2026-05-28T03:24:06+00:00

I created a silverlight template control. Thouse control consist 4 elements: 2 textbox and

  • 0

I created a silverlight template control. Thouse control consist 4 elements: 2 textbox and 2 textblock.
markup (in generic.xaml):

<Style TargetType="local:InputForm">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:InputForm">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Login" Grid.Column="0" Grid.Row="0"/>
                            <TextBlock Text="Password" Grid.Column="0" Grid.Row="1"/>
                            <TextBox x:Name="LoginTextBox" Grid.Column="1" Grid.Row="0" Text="Login..."/>
                            <TextBox x:Name="PasswordTextBox" Grid.Column="1" Grid.Row="1" Text="Password..."/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

In code file I get the textbox from template and set Foreground.Opacity property equels 0.5.
code:

public class InputForm : Control
{
    private TextBox _loginTextBox;
    private TextBox _passwordTextBox;

    public InputForm()
    {
        this.DefaultStyleKey = typeof(InputForm);
    }

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();

        _loginTextBox = this.GetTemplateChild("LoginTextBox") as TextBox;
        _passwordTextBox = this.GetTemplateChild("PasswordTextBox") as TextBox;

        SetInActive();
    }

    private void SetInActive()
    {
        _loginTextBox.Foreground.Opacity = .5;
        _passwordTextBox.Foreground.Opacity = .5;
    }
}

When I added this control in my silverlight application all textboxs element began represent text with Foreground.Opacity = 0.5
Start application:

First tab before oper login tab

Select “Login” tab:

Login tab

Back to “Some infromation” tab:

First tab after open login tab

Sample located here: http://perpetuumsoft.com/Support/silverlight/SilverlightApplicationOpacity.zip
Is it silverlight bug or I do something wrong?

  • 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-28T03:24:06+00:00Added an answer on May 28, 2026 at 3:24 am

    The problem is that the Foreground property is of type Brush which is a reference type (a class).

    When you assign .Opacity = 0.5 you are changing the opacity value of the referenced Brush. All other elements that are referencing the same brush will be affected.

    Ordinarily we would use a Storyboard in VisualStateManager in the control template to specify the visual appearance of a control in different “states”.

    However a quick fix for your code would be:

    private void SetInActive()     
    {     
        Brush brush = new SolidColorBrush(Colors.Black) { Opacity = 0.5 };
        _loginTextBox.Foreground = brush    
        _passwordTextBox.Foreground= brush
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a custom control for use in my Silverlight application. Its template is
I created a silverlight app (without website) named TestApp , with one TextBox: <UserControl
I have created a nice silverlight control doing exactly what I want it to
Is it possible to create a .xaml (silverlight) control in a web application project?
When creating a control style & template in Blend for a WPF application, I
I have developed a simple Silverlight control. I created this by using the Silverlight
I have just created a new silverlight app using Silverlight navigation template. All went
I am trying to create a silverlight imagebutton control. the xaml and code-behind will
The default Silverlight project template creates a file called App.xaml. What is this file
I have created a new Silverlight 4 solution using the Business Application template. The

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.