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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:22:31+00:00 2026-05-20T09:22:31+00:00

I’ve set up a simple Silverlight 4 control which is supposed to switch the

  • 0

I’ve set up a simple Silverlight 4 control which is supposed to switch the visibility of two textboxes based on a public property. I add the control to a view and set the databinding of the control’s property to a property of the parent view’s viewmodel.
When a change in the parent viewmodel’s property occurs, nothing happens in the usercontrol. Although it’s bound, the OnPropertyChanged doesnt seem to interest the bound property of the user control. Below is the code of the user control.

<UserControl x:Class="Controls.EAPPasswordBox"
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" x:Name="_root" >

<Grid x:Name="LayoutRoot" Background="White">
    <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top">
        <PasswordBox x:Name="pwdBox" />
        <TextBox x:Name="txtBox" />
    </StackPanel>
</Grid>

public partial class EAPPasswordBox : UserControl, INotifyPropertyChanged
{
    public bool ShowText
    {

        get { return (bool)GetValue(ShowTextProperty); }
        set { 

            SetValue(ShowTextProperty, value);
               if (value == true)
               {
                   this.pwdBox.Visibility = System.Windows.Visibility.Collapsed;
                   this.txtBox.Visibility = System.Windows.Visibility.Visible;
               }
               else
               {
                   this.pwdBox.Visibility = System.Windows.Visibility.Collapsed;
                   this.txtBox.Visibility = System.Windows.Visibility.Visible;
               }
        }

    }

    private Visibility _PwdBoxVisibility;

    public Visibility PwdBoxVisibility
    {
        get { return _PwdBoxVisibility; }
        set
        {
            _PwdBoxVisibility = value; NotifyPropertyChanged("PwdBoxVisibility");
        }
    }

    private Visibility _TxtBoxVisibility;

    public Visibility TxtBoxVisibility
    {
        get { return _TxtBoxVisibility; }
        set
        {
            _TxtBoxVisibility = value; NotifyPropertyChanged("TxtBoxVisibility");
        }
    }


    public static readonly DependencyProperty ShowTextProperty =
         DependencyProperty.Register("ShowText", typeof(bool), typeof(EAPPasswordBox),null);

    public EAPPasswordBox()
    {
        InitializeComponent();
    }

    private static void OnShowTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {

    }

    public event PropertyChangedEventHandler PropertyChanged;

    private void NotifyPropertyChanged(String info)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(info));
        }
    }

}

Here is how I use it in my parent view:

<local:EAPPasswordBox x:Name="pwdBox"
                Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" ShowText="{Binding showPassword, Mode=TwoWay}"></local:EAPPasswordBox>


private bool _showPassword;
    public bool showPassword
    {
        get
        {
            return _showPassword;
        }
        set
        {
            _showPassword = value;
            RaisePropertyChanged("showPassword");
        }
    }

When the “showPassword” in the parent view’s viewmodel changes, nothing happens in the user control, and it’s driving me crazy 🙂
Any ideas? Thank you.

  • 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-20T09:22:31+00:00Added an answer on May 20, 2026 at 9:22 am

    Updates to bound Dependency Properties don’t occur with the normal get/set accessors of the property but behind the scenes. As such the only way to intercept when the value is changed is to provider a DependencyPropertyChangedEventHandler in the PropertyMetadata when you create the Dependency Property.

    As follows:

    
    public static readonly DependencyProperty ShowTextProperty =
             DependencyProperty.Register("ShowText", typeof(bool), typeof(EAPPasswordBox), new PropertyMetadata(ShowTextPropertyChanged));
    
    private static void ShowTextPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
    {
        EAPPasswordBox passwordBox = sender as EAPPasswordBox;
    
        if (passwordBox != null)
        {
            passwordBox.SetVisibilityOfTextBoxes();
        }
    }
    
    

    Hope it helps.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a text area in my form which accepts all possible characters from
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.