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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:27:11+00:00 2026-05-30T19:27:11+00:00

I have created sample User Control RestrictedBox.xaml <UserControl.Resources> <Converters:EnumToVisibilityConverter x:Key=enumToVisConverter /> <Converters:EnumToVisibilityConverterReverse x:Key=enumToVisConverterReverse />

  • 0

I have created sample User Control

RestrictedBox.xaml

 <UserControl.Resources>
        <Converters:EnumToVisibilityConverter x:Key="enumToVisConverter" />
        <Converters:EnumToVisibilityConverterReverse x:Key="enumToVisConverterReverse" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White" Width="Auto">
        <StackPanel Margin="0">
            <TextBox Text="{Binding Value}" Visibility="{Binding Type,Converter={StaticResource enumToVisConverter}}" BorderBrush="Green" />
            <PasswordBox Password="{Binding Value}" Visibility="{Binding Type,Converter={StaticResource enumToVisConverterReverse}}" BorderBrush="Red" />
        </StackPanel>
    </Grid>

RestrictedBox.xaml.cs

public partial class RestrictedBox : UserControl
    {
        public RestrictedBox()
        {
            InitializeComponent();
            //If i bind static value and uncomment following line then it is working.
            //If i bind static value and comment following line then it is not working
            this.DataContext = this;
            //Dynamic binding does not work using this code.  
        }

        public string Value
        {
            get { return (string)GetValue(ValueProperty); }
            set { SetValue(ValueProperty, value); }
        }
        public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(string), typeof(RestrictedBox), new PropertyMetadata("", ValueChanged));
        private static void ValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
        }
        public Mode Type
        {
            get { return (Mode)GetValue(TypeProperty); }
            set { SetValue(TypeProperty, value); }
        }
        public static readonly DependencyProperty TypeProperty = DependencyProperty.Register("Type", typeof(Mode), typeof(RestrictedBox), new PropertyMetadata(TypeChanged));
        private static void TypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
        }
    }

LoginViewModel.cs

public class LoginViewModel : INotifyPropertyChanged, IRegionMemberLifetime
{
        private string _UserName = "Imdadhusen Sunasara";
        public string UserName
        {
            get { return _UserName; }
            set
            {
                _UserName = value;
                OnPropertyChanged("UserName");
            }
        }
}

LoginView.xaml (This following line does not work with binding)

<control:RestrictedBox Value="{Binding UserName}" Type="Text" />

This is working (with static binding)

<control:RestrictedBox Value="Imdadhusen" Type="Text" />

Thanks,
Imdadhusen

  • 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-30T19:27:12+00:00Added an answer on May 30, 2026 at 7:27 pm

    Actually It should work. Can you please verify that the DataContext of parent container of below control doesn’t refering to any other property of viewmodel.

    <control:RestrictedBox Value="Imdadhusen" Type="Text" />
    

    eg. Something like below.

    <StackPanel DataContext={Binding CurrentUser}>
    
    <control:RestrictedBox Value="{Binding UserName}"
    
     Type="Text" />
    
    </StackPanel>
    

    May be this help you….

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

Sidebar

Related Questions

I have created a very simple user control ActiveX with a simple button that
Maybe someone can help me out. I have created a simple web user control,
I have created a sample report with crystal report 10. Now, I wanna to
I have created a sample java socket application. I used Socket s = new
I have created a CPTTradingRangePlot using the up-to-date sample code as an example. The
I have opened a sample ASP.NET MVC project. In HomeController I have created a
I have a sample project here on github where I created a c++ wrapper
Background: I have created sample windows application for learning to implement localization. My each
I have created an XtraTreeList control that is bound to my bindingSource and it
I have created a custom TaskButton control that takes an image and text. 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.